Curious working with objects

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2007
Posts: 68
Reputation: Rhohitman is an unknown quantity at this point 
Solved Threads: 4
Rhohitman's Avatar
Rhohitman Rhohitman is offline Offline
Junior Poster in Training

Curious working with objects

 
0
  #1
Oct 2nd, 2009
  1. struct Table
  2. {
  3. char* aTag;
  4. char* bTag;
  5. };
  6. int main()
  7. {
  8. Table T1;
  9. cout<<T1.aTag;
  10. cout<<T1.bTag;
  11. return 0;
  12. }

This might be crazy but... i really need to know
is there any way to so that we can only write
  1. cout<<aTag
  2. 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...
Last edited by Rhohitman; Oct 2nd, 2009 at 6:20 pm.
Chazing Dreams ;'P
Shhhh.......ZZzzzzzzzzzzzzzzzzzzzz.....
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,408
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 181
firstPerson's Avatar
firstPerson firstPerson is offline Offline
Nearly a Posting Virtuoso

Re: Curious working with objects

 
0
  #2
Oct 2nd, 2009
Why ?

Maybe something like this :

  1. #include <iostream>
  2. #include <string>
  3.  
  4. using std::cout;
  5. using std::string;
  6. using std::endl;
  7.  
  8. namespace Curious
  9. {
  10. string mystery = "Magic";
  11.  
  12. struct Wonder
  13. {
  14. Wonder(string msg) { mystery = msg; }
  15.  
  16. };
  17. }
  18. int main()
  19. {
  20. using namespace Curious;
  21.  
  22. cout<<mystery<<endl;
  23. Wonder why("What is going on ? ");
  24. cout << mystery << endl;
  25.  
  26.  
  27. return 0;
  28. }
1) What word becomes shorter if you add a letter to it? 
      [ Solved by : niek_e, Paul Thompson, SgtMe, murtan, xavier666, jonsca]
2) What does this sequence  equal to :  (.5u - .5a)(.5u-.5b)(.5u-.5c) ...
      [*solved by : murtan, xavier666]
3) What is the 123456789th prime numer?
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 68
Reputation: Rhohitman is an unknown quantity at this point 
Solved Threads: 4
Rhohitman's Avatar
Rhohitman Rhohitman is offline Offline
Junior Poster in Training

Re: Curious working with objects

 
0
  #3
Oct 2nd, 2009
you are just changing the string ... which is not the member variable.. itself and printing ... its funny...
Chazing Dreams ;'P
Shhhh.......ZZzzzzzzzzzzzzzzzzzzzz.....
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 247
Reputation: sfuo is on a distinguished road 
Solved Threads: 29
sfuo's Avatar
sfuo sfuo is offline Offline
Posting Whiz in Training

Re: Curious working with objects

 
0
  #4
Oct 2nd, 2009
Take a look at this thread. I think this is what you are looking for.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1,408
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 181
firstPerson's Avatar
firstPerson firstPerson is offline Offline
Nearly a Posting Virtuoso

Re: Curious working with objects

 
0
  #5
Oct 2nd, 2009
Originally Posted by Rhohitman View Post
you are just changing the string ... which is not the member variable.. itself and printing ... its funny...
Well the idea was to use the string, inside the struct as if it was
a member.
1) What word becomes shorter if you add a letter to it? 
      [ Solved by : niek_e, Paul Thompson, SgtMe, murtan, xavier666, jonsca]
2) What does this sequence  equal to :  (.5u - .5a)(.5u-.5b)(.5u-.5c) ...
      [*solved by : murtan, xavier666]
3) What is the 123456789th prime numer?
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC