0
struct Table
{
char* aTag;
char* bTag;
};
int main()
{
Table T1;
cout<<T1.aTag;
cout<<T1.bTag;
return 0;
}

This might be crazy but... i really need to know
is there any way to so that we can only write

cout<<aTag 
cout<<bTag

instead of T1.aTag like we do in namespace by using namespace <something> for a block.
Can in be done for pointers T1->aTag .
I tried something but have to write each of them for different object...

Edited by rhoit: n/a

3
Contributors
4
Replies
6
Views
8 Years
Discussion Span
Last Post by firstPerson
0

Why ?

Maybe something like this :

#include <iostream>
#include <string> 
 
using std::cout;
using std::string;
using std::endl;

namespace Curious
{
	string mystery = "Magic";

	struct Wonder
	{
		Wonder(string msg) { mystery = msg; }

	};
}
int main()
{  
	using namespace Curious;

	cout<<mystery<<endl;
	Wonder why("What is going on ? ");
	cout << mystery << endl;
 

	return 0;
}
0

you are just changing the string ... which is not the member variable.. itself and printing ... its funny... :P

0

you are just changing the string ... which is not the member variable.. itself and printing ... its funny... :P

Well the idea was to use the string, inside the struct as if it was
a member.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.