Alright, I need a lot of help.

Discussion in 'C Programming' started by Blind Melon, Mar 23, 2007.

  1. Blind Melon

    Blind Melon

    Joined:
    Mar 23, 2007
    Messages:
    2
    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.
     
    Blind Melon, Mar 23, 2007
    #1
    1. Advertising

  2. Blind Melon

    Blind Melon

    Joined:
    Mar 23, 2007
    Messages:
    2
    Anyone able to help me out?
     
    Blind Melon, Mar 24, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TWlrZUppbmdKaW5n?=

    HELP Access DB, ASP.NET 2.0 and whole lot of pain

    =?Utf-8?B?TWlrZUppbmdKaW5n?=, Dec 6, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    475
    Patrice
    Dec 6, 2005
  2. matt
    Replies:
    9
    Views:
    422
    Andrew Thompson
    Oct 27, 2004
  3. =?Utf-8?B?YXR6aHVxag==?=
    Replies:
    3
    Views:
    418
    Teemu Keiski
    Apr 22, 2006
  4. Greg
    Replies:
    3
    Views:
    511
    =?UTF-8?B?UmFsZiBNw7ZybGVy?=
    Apr 15, 2005
  5. Mike Kingscott

    Alright smarty-pants, solve this problem:

    Mike Kingscott, Oct 29, 2003, in forum: ASP .Net Web Controls
    Replies:
    8
    Views:
    153
    Mike Kingscott
    Nov 5, 2003
Loading...

Share This Page