Thread: Template/classes/strings

  1. #16
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    does anyone know how I can fix the "1.#QNAN" error or not?
    Yes; everyone who has posted.

    I do like these easy questions.

    Soma

  2. #17
    Registered User
    Join Date
    May 2011
    Posts
    9
    please tell me how to fix the "1.#QNAN" error

  3. #18
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    You don't have any code posted in this thread that involves double variables in any way shape or form. How do we know what you've done to that poor defenseless double variable? All we see is you trying to print out some "PACKAGE" things, and nobody knows what you think that should do either.

  4. #19
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by llVIU View Post
    look, please stop with the irrelevant talk, does anyone know how I can fix the "1.#QNAN" error or not? I'd very much appreciate if I could be helped only with the "1.#QNAN" error and nothing else, *NOTHING* else please, thank you very much
    OK look, why have I been telling you to fix your code, which is a mess? And why do the others try to tell you to fix it?
    Because it's a mess, and it's unreadable. If we can't put any effort into reading your code, how can we know what you are doing wrong?

    You might prefer to write unreadable code, and again, it's your choice. But when you're asking for help, you have to adjust to the standards of the community you're asking, or they won't help you at all. This is just an advice. To follow it or not is up to you, but you'll notice you'll get more helpful responses if you do fix this.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #20
    Registered User
    Join Date
    May 2011
    Posts
    9
    nvm
    Code:
    #include <iostream>
    #include <ostream>
    #include <string>
    using namespace std;
    
    template <class T>
    class DATE_EXP
    {
        T NAME_EXP,ADRESS_EXP;
    public:
        DATE_EXP(T first,T second)
        {
            NAME_EXP=first,ADRESS_EXP=second;
        }
        void INSERT_DATE_EXP ()
        {
            getline(cin,NAME_EXP);
            getline(cin,ADRESS_EXP);
            cout << "NAME_EXP IS " << NAME_EXP << "\n";
            cout << "ADRESS_EXP IS " << ADRESS_EXP << "\n";
        };
    }; //class DATE_EXP
    
    
    template <class T>
    class KG_GC
    {
        T KG,GC;
    public:
        KG_GC(T first,T second)
        {
            KG=0,GC=0;
        }
        void INSERT_KG_GC ()
        {
            cin >> KG;
            cin >> GC;
            cout << "KG:"<< KG <<"\n";
            cout << "GC:"<< GC <<"\n";
    
        };
    }; //class KG_GC
    
    template <class T>
    class CALC_COST
    {
        T kg,gc;
    public:
        CALC_COST(T kg,T gc)
        {
            kg=0,gc=0;
        }
        T DA_REZULTATU ()
        {
            return (kg*gc);
        }
    };
    
    
    
    int main()
    {
        int A0=0;
        do
        {
            cout<<"CHOOSE PROGRAM NUMBER:25\n";
            int B0=25;
            switch(B0)
            {
                case  1:
                {
                    cout << " 0=EXIT\n 1=COMMAND LIST\n25=2505111-T2-2-1\n";
                    break;
    
                }
                case  0:
                {
                    return 0;
    
                }
                case 25:
                {
                    string NAME_EXP_TEMP, ADRESS_EXP_TEMP;
                    DATE_EXP<string> EXP_TEMP(NAME_EXP_TEMP,ADRESS_EXP_TEMP);
                    EXP_TEMP.INSERT_DATE_EXP();
    
                    double KG_TEMP = 0,GC_TEMP = 0;
                    KG_GC<double>KG_GC_TEMP(KG_TEMP,GC_TEMP);
    
                    KG_GC_TEMP.INSERT_KG_GC ();
    
                    cout << "\n";
                    cin >> A0;
    
                    CALC_COST<double>CALC_COST_2(1,2);
                    CALC_COST_2.DA_REZULTATU ();
    
                    cout << "\n";
                    cin >> A0;
    
                    break;
                }//switch B0=4
            }//switch B0
        }  while(1);//doodoo
        return 0;
    }//main
    Last edited by llVIU; 05-25-2011 at 03:24 PM.

  6. #21
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Your insert function is supposed to return a double. But:
    Code:
    template <class P>
                P KG_GC<P>::INSERT_KG_GC ()
                {
                    cin >> KG;
                    cin >> GC;
                    cout << "KG:"<< KG <<"\n";
                    cout << "GC:"<< GC <<"\n";
                    
                };
    You didn't bother. This is why your compiler is saying "control reaches end of non-void function".

  7. #22
    Registered User
    Join Date
    May 2011
    Posts
    9
    yea thanks I got that part now

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inheritance and Template Classes
    By brunion1 in forum C++ Programming
    Replies: 3
    Last Post: 05-02-2011, 02:23 AM
  2. Specifying Allowed Template Classes
    By nine-hundred in forum C++ Programming
    Replies: 3
    Last Post: 08-30-2007, 12:22 AM
  3. templated members in non-template classes
    By drrngrvy in forum C++ Programming
    Replies: 3
    Last Post: 04-07-2007, 01:38 PM
  4. Passing Template values on to other classes
    By vinsta18 in forum C++ Programming
    Replies: 5
    Last Post: 10-20-2004, 05:26 PM
  5. Template Classes
    By AdioKIP in forum C++ Programming
    Replies: 5
    Last Post: 02-24-2002, 06:13 PM