Results 1 to 4 of 4

Thread: struct problem...

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2007
    Posts
    47
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    12

    Red face Re: struct problem...

    Quote Originally Posted by aamer4yu View Post
    U should have posteed this in General programming... nothing specific to Qt...

    neways this should help u...


    Qt Code:
    1. struct refer{
    2. double Are;
    3. double Ere;
    4. };
    5.  
    6. class newstruct{
    7. public:
    8. newstruct();
    9. struct refer refer1;
    10. struct refer a(double b,double c);
    11. };
    12. In the .cpp file:
    13. refer newstruct::a(double b,double c)
    14. {
    15. refer1.Are=b;
    16.  
    17. refer1.Ere=c;
    18. cout<<refer1.Aref<<endl
    19. <<refer1.Eref<<endl;
    20.  
    21. return(refer1);
    22. }
    23.  
    24. newstruct objNewstruct;
    25. refer r2 = objNewstruct.a(3,4);
    To copy to clipboard, switch view to plain text mode 


    hope this helps...
    I just change the defination of struct a,just as you said.Then its ok!
    Thank you very much!

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 334 Times in 317 Posts

    Default Re: struct problem...

    struct a ???
    i guess a is a member function of the class newstruct.
    The mistake u were making is that u were trying to return refer1... in return u mention return types,,,, not return data.

Similar Threads

  1. Replies: 16
    Last Post: 23rd May 2008, 11:12
  2. Problem porting Kivio MP on win32 from Qt 3 to Qt 4
    By Amanda in forum Qt Programming
    Replies: 2
    Last Post: 26th October 2006, 20:40
  3. problem with saving QCstrings
    By nass in forum Qt Programming
    Replies: 3
    Last Post: 5th October 2006, 16:12
  4. Replies: 16
    Last Post: 7th March 2006, 16:57
  5. Problem with pointers while using localtime() and time()
    By jamadagni in forum General Programming
    Replies: 7
    Last Post: 11th January 2006, 16:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.