I am just trying to design a class to set and get the details of a student in C++.
So,to set the details of the student,i called set_data(name,roll)
method.But this compilation error is coming.I have passed the same data type as actual arguments to the function as expected.I cant understand why error is coming.
G:\>g++ 5.cpp
5.cpp: In function 'int main()'
5.cpp:26:23: warning: deprecate
rite-strings]
obj.set_data("asdf",15);
The code is ---
#include<iostream>
using namespace std;
#include<string.h>
#include<stdlib.h>
class pntr_obj
{
char *name;
int roll;
public:
void set_data(char *name,int roll)
{
this->name=name;
this->roll=roll;
}
void print()
{
cout<<"name is "<<this->name<<endl;
cout<<"roll is "<<this->roll<<endl;
}
};
int main()
{
pntr_obj obj;
obj.set_data("asdf",15);
obj.print();
return 0;
}