Colleagues,
The program written in class is not compiled.
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string> using namespace cv; using namespace std; class Person { int age; string name; string surname; public: void dataChange (int y, string m_name, string m_surname) { age=y; name=m_name; surname=m_surname; } void print() { cout<< "My name is "<<name<<" "<<surname<<" and I am "<<age<< " years old"<<endl; } }; int main() { Person me = ( 28, "Stepan", "Sokol"); me.print(); me.dataChange(27, "Esteban", "Falke"); me.print(); getchar(); return 0; } There are errors on the line of declaration of the Person class me variable:
Error 1 error C2440: 'initializing': cannot convert from 'const char [6]' to 'Person' c: \ users \ u20y36 \ desktop \ progs \ project2 \ project2 \ source.cpp 32 1 Project2
2 IntelliSense: no "const char [6]" to "Person" c: \ Users \ u20y36 \ Desktop \ Progs \ Project2 \ Project2 \ Source.cpp 32 14 Project2
What is the problem? Thank you.