-
November 24th, 2013, 03:03 PM
#1
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.
-
November 24th, 2013, 03:36 PM
#2
Re: Error returning object from function
-
November 24th, 2013, 03:39 PM
#3
Re: Error returning object from function
I get compile time errors.
Originally Posted by GCDEF
Define "doesn't work".
-
November 24th, 2013, 03:42 PM
#4
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. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
November 24th, 2013, 04:23 PM
#5
Re: Error returning object from function
Originally Posted by deathmetal
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|