Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 07-18-2002, 05:22 PM   #1 (permalink)
brtklt
Registered User
 
Join Date: Jul 2002
Location: Dallas, TX
Posts: 2
brtklt is on a distinguished road
Send a message via Yahoo to brtklt
trouble calling auxiliary function in a class

I'm trying to pass an auxiliary function w/in a class implementation. The compiler error I'm getting is "undefined reference to 'functionname'" in every class memeber function I call the auxiliary function from. Here's the code if anyone can help me figure this out:




Code:


// IMPLENTATION FILE FOR timetype.h



#include "timetype.h"

#include <iostream>



using namespace std;



void ConvertTime( long, int&, int&, int& );



long secsin;



TimeType::TimeType()

{

        secs = 2000;

}



void TimeType::Set( /* in */ int hours,

                    /* in */ int minutes,

                    /* in */ int seconds )

{

        while (hours != 24 && minutes != 0 && seconds != 0)

        {

                while (seconds < 60)

                        secs += 1;

                seconds = 0;

                if (minutes == 59 && hours < 24)

                {

                        hours++;

                        minutes = 0;

                }

                else

                        minutes++;

        }

}



void TimeType::Increment()

{

        secs++;

}



void TimeType::Write() const

{

        int hrs, mins, seconds;

        ConvertTime( secs, hrs, mins, seconds);

        if (hrs <  10)

                cout << '0';

        cout << hrs << ':';

        if (mins < 10)

                cout << '0';

        cout << mins << ':';

        if (seconds < 10)

                cout << '0';

        cout << seconds;

}



void TimeType::WriteAMorPM() const

{

        int hrs, mins, seconds;

        ConvertTime( secs, hrs, mins, seconds);

        bool am;

        int temphrs = hrs;



        if (hrs > 12)

        {

                temphrs -= 12;

                am = false;

        }

        if (hrs < 10)

                cout << '0';

        cout << temphrs << ':';

        if (mins < 10)

                cout << '0';

        cout << mins << ':';

        if (seconds < 10)

                cout << '0';

        cout << seconds;

        if (am)

                cout << "AM\n";

        else

                cout << "PM\n";

}



bool TimeType::Equal( /* in */ TimeType otherTime ) const

{

        return (secs == otherTime.secs);

}



bool TimeType::LessThan( /* in */ TimeType otherTime ) const

{

        return (secs < otherTime.secs);

}



long TimeType::Minus ( /* in */ TimeType otherTime ) const

{

        if (otherTime.secs > secs)

                return otherTime.secs - secs;

        else

                return secs - otherTime.secs;

}



void ConvertTime( /*in*/  long secsin,

                  /*out*/ int hrs,

                  /*out*/ int mins,

                  /*out*/ int seconds )

{

        while (secsin != 0)

        {

                if (secsin > 60)

                {

                        for (int i = 0; i < 60; i++)

                        {

                                seconds++;

                                secsin--;

                        }

                        if (mins == 59)

                        {

                                hrs++;

                                mins = 0;

                        }

                        else

                                mins++;

                        seconds = 0;

                }

                else

                        seconds++;

        }

}
brtklt is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
to put data methods inside class or not? sde Java 2 05-25-2004 04:09 PM
pointer to function with class? Kportertx Standard C, C++ 5 04-11-2003 05:12 AM


All times are GMT -8. The time now is 09:12 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting