Error returning object from function
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Error returning object from function

  1. #1
    Join Date
    Oct 2013
    Posts
    12

    Error returning object from function

    Code:
    class Main{
    	class B b_obj;
    	C c_obj=b_obj.test("some",89); // I cannot get this done.!
    
    }
    Below are .h files:
    
    class B{
    	public:
    	
    	C* test(const char *, int); /// this doesn't work
    	constructor
    	
    	//member variables
    }
    
    class C{
    	public:
    	constructor
    	
    	private:
    	map<string, vector<bol>> name;
    
    }
    C* test(const char *, int); /// this doesn't work
    C& test(const char *, int); /// this doesn't work
    name* test(const char *, int); //cannot work as name is private

    However,
    map<string, vector<bol>> test(const char *, int); works.
    I know second thing will work, but how to take reference of class object?

    I have include .h file in main, B and C, wherever it is required.

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,229

    Re: Error returning object from function

    Define "doesn't work".

  3. #3
    Join Date
    Oct 2013
    Posts
    12

    Re: Error returning object from function

    I get compile time errors.
    Quote Originally Posted by GCDEF View Post
    Define "doesn't work".

  4. #4
    Join Date
    Dec 2012
    Location
    England
    Posts
    2,854

    Re: Error returning object from function

    It would be more useful if you posted the actual full code rather than just pseudo code that says things like 'constructor'.
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

  5. #5
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,229

    Re: Error returning object from function

    Quote Originally Posted by deathmetal View Post
    I get compile time errors.
    Jeeze, is it too much trouble to actually post the errors. Ms. Cleo doesn't post here any more.

    Looking at what you posted, you're using a C before it's been defined. Without real code and real errors, it's just a guess.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center