Alright, I need a lot of help.

Joined
Mar 23, 2007
Messages
2
Reaction score
0
So I've started the class Data Structures, and we're about 3 months into it. We're currently at stacks, and we're doing our 3rd project of the course. Our first one consisted of us overloading operators in OOD. Our 2nd project didn't use OOD at all, we just used regular old .cpp and creating everything there (forget the name currently). Now our 3rd project brings us back around to OOD. I must first start off by saying OOD is so much harder, mainly because I'm not nearly as used to it yet, so it's still taking a while to get used to considering we've only had one project on it, and I haven't given much time to trying it out (because I haven't really needed it).

So anyway, our 3rd project is a postfix calculator. I'm sure everyone is familiar? If not... infix is normal notation of writing equations... so X+Y is infix notation... postfix would be XY+... and we're only to do the characters and then incorporate them into another file that'll actually calculate the numbers inputted using our notation that's been created. So we're only to get the postfix notation in letter form. I think I know how to do this step, but my problem currently is trying to set up my header file and the implementation file... my weakness here is OOD.

Here goes. I am currently trying to set up my default constructors. I have one constructor that has no parameters, and one that has a parameter. Alright, since it's always good to just keep everything abstract, I'm using templates, but was also thinking since this is mainly specific for strings, I won't have to use a template? But I've tried without using that and have found that if you don't use a template, then C++ automatically assigns the value as int, and that's no good, so yeah... I have to use a template.

So I'll just show my code instead of explaining the rest:
(I'll just show the functions instead of everything)

Header
public:
postFix();
postFix(string a);
void print() const;

Implementation
template <class Type>
postFix<Type>:: postFix()
{
Type next2;
}

template <class Type>
postFix<Type>:: postFix(Type a)
{
Type next2;
next2 = a;
}

template <class Type>
void postFix<Type>:: print() const
{
cout << next2 << endl;
}



And I get two LNK2019 errors. I'm really confused as to why it doesn't work. I think I know the error is within the constructor that takes the parameter, but I do not know how to fix it. So if someone could just point me in the right direction, while not giving me the answer, that'd be awesome! Thanks for taking the time to read this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top