did it for my self but I think someone will need this
Code:
#include <iostream>
#include <string>
using namespace std;
////////////////////////////////////////////////////////////////////////////////////////////////////
class login
{
public:
string name;
string givename ()
{
getline (cin, name);
cout << "we are in class1 " << name << endl;
return name;
}
string show_name (string new_name)
{
name = new_name;
cout << "we are in class1 " << name << endl;
}
};
////////////////////////////////////////////////////////////////////////////////////////////////////
void myfunc(string name)
{
cout << "we are in myfunc " << name << endl;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
class myclass2
{
public:
string namew;
string changename;
int name (string nameq)
{
cout << "we are in class2 " << nameq << endl;
}
string nameen (string nameq)
{
getline (cin, changename);
nameq = changename;
cout << "we are in class2 changing name " << nameq << endl;
return nameq;
}
};
////////////////////////////////////////////////////////////////////////////////////////////////////
int main ()
{
login log;
string y;
y = log.givename();
cout << "we are in int main " << y << endl;
////////////////////////////////////////////////////////////////////////////////////////////////////
//we have made a string and pass it to int main
////////////////////////////////////////////////////////////////////////////////////////////////////
//we have to pass this info to function now
////////////////////////////////////////////////////////////////////////////////////////////////////
myfunc(y); // this value passes to myfunc even if numbers aren't exact number
// but this valuable must not be declared 2 times with int or anything else
////////////////////////////////////////////////////////////////////////////////////////////////////
// we have now pass name to myfunc
////////////////////////////////////////////////////////////////////////////////////////////////////
// we have to pass this info from myfunc to myclass
////////////////////////////////////////////////////////////////////////////////////////////////////
myclass2 clas;
clas.name(y);
cout << "\n\nwe are in main and changing name\n\n" << endl;
y = clas.nameen(y);
cout << "we are in main and changing name " << y << endl;
////////////////////////////////////////////////////////////////////////////////////////////////////
// we call myfunc and look at our name
// my func hasn't change but y value has
////////////////////////////////////////////////////////////////////////////////////////////////////
myfunc(y);
////////////////////////////////////////////////////////////////////////////////////////////////////
//now we would like to change the begining name we used
////////////////////////////////////////////////////////////////////////////////////////////////////
log.show_name (y);
////////////////////////////////////////////////////////////////////////////////////////////////////
//we change it with value y from this scope and send value to begining
////////////////////////////////////////////////////////////////////////////////////////////////////
cout << "\n" << endl;
system ("pause");
return 0;
}