error: conversion from 'const char [15]' to non-scalar type 'MyClass' requested
error: conversion from 'const char [13]' to non-scalar type 'MyClass' requested
error: conversion from 'const char [13]' to non-scalar type 'MyClass' requested
Ce inseamna aceaste erori si ce modificari trebuie sa fac ?
Code: Select all
#include <iostream>
#include <iostream>
#include <cstring>
using namespace std;
class MyClass
{
private:
string *Name;
public:
MyClass(string *Name)
{
this->Name = new string;
this->Name = Name;
}
string *getName()
{
return Name;
}
};
int main()
{
MyClass obj[3] = {"Popescu Bogdan", "Dobre Virgil", "Afrem Dragos"};
MyClass *ptr;
ptr = &obj[0];
cout << endl;
for (int i=0; i<3; i++)
{
cout << " " << ptr->getName() << endl;
ptr++;
}
return 0;
}