Hello. I am a new member of this web site. The reason for joining is that when I experienced some problems , I found most solutions on this website. Sadly, I cannot find all answers to my problems.
That's why I am here now and I want to ask you something.
The following code compiles and works. But the output shows
5 + address of "Hello". But I want it to show 5Hello.
I know that .c_str() returns a const char*, that's why I need your help :P So what is the code to show the output 5Hello?
btw, I've also heard something about std::wcout, but that didnt work for me either.
#include <windows.h>
#include <iostream>
#include <string.h>
class CPerson
{
int *PAge;
std::wstring *PName;
public:
CPerson (int, std::wstring);
int ShowAge();
std::wstring ShowName();
};
CPerson::CPerson(int AAge, std::wstring AName)
{
PAge = new int;
PName = new std::wstring;
*PAge = AAge;
*PName = AName;
}
int CPerson::ShowAge()
{
return *PAge;
}
std::wstring CPerson::ShowName()
{
return *PName;
}
int main ()
{
CPerson BPerson(5, TEXT("Hello"));
std::cout << BPerson.ShowAge() << BPerson.ShowName().c_str();
Sleep(1000); // I used this to see what the output shows
return 0;
}