By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,441 Members | 998 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,441 IT Pros & Developers. It's quick & easy.

Return class(a) pointer in another class(b) function

P: 18
So i've been working on a program in c++ that uses classes, and i am having a few problems with returning a class value from another class's function.

So i have a class called X, which is essentially a class that defines a linked list, and has some of the basic operations. In that class i have a '[]' operator that is overloaded with each value in the linked list. The operator can also override values in the linked list using
Expand|Select|Wrap|Line Numbers
  1. *classxvariable[i] = "string";
the function for that is
Expand|Select|Wrap|Line Numbers
  1. std::string* X::operator[](long index)
I also have another class called Y which calls upon class X for it's operator function
Expand|Select|Wrap|Line Numbers
  1. X* Y::operator[](long index)
Class Y is also a linked list

the problem is for
Expand|Select|Wrap|Line Numbers
  1. X* Y::operator[](long index){}
i'm not sure how to go about getting the function to return X*
from the class Y

Sep 12 '10 #1
Share this Question
Share on Google+
1 Reply

P: 18
Never mind i figured it out.
Sep 12 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.