Error instantiating an object of a class in QT Creator C ++

0

I need to create a AgregarProyecto method, which allows you to add a new project to a list.

My problem is this: When wanting to make an instance of class proyecto , which receives 3 arguments, I get the following error:

  

error: conversion from 'project *' to non-scalar type 'project'   requested        project a Project = new project (name, description, directory);

The method is as follows:

void MainWindow::agregarProyecto(QString nombre, QString descripcion, QString directorio)'{'
    proyecto unProyecto = new proyecto (nombre,descripcion,directorio);
    this->listaProyectos.append(unProyecto);
}
    
asked by marcos vasquez 12.05.2017 в 22:17
source

2 answers

2
proyecto unProyecto = new proyecto (nombre,descripcion,directorio);

unProyecto should be a pointer:

proyecto* unProyecto = new proyecto (nombre,descripcion,directorio);
//      ^ AQUI!!!
    
answered by 12.05.2017 / 23:11
source
0

A pointer to class Foo is declared and starts in the following way:

Foo* myObjeto = new Foo (...);

What is missing is the pointer operator * .

    
answered by 13.05.2017 в 18:03