Classes in C++

This is a discussion on Classes in C++ within the C++ Programming forums, part of the General Programming Boards category; I don't know. I'm not cool for school. Also, I'm not in the industry. I do know, however, that anybody ...

  1. #16
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    907
    I don't know. I'm not cool for school. Also, I'm not in the industry. I do know, however, that anybody with an imagination who has played video games can think of some sweet, good-looking idea. It's the designers who understand the mechanics of development who have their games written.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  2. #17
    Registered User
    Join Date
    Nov 2008
    Posts
    23
    I totally have the imagination and even some artsyness (is that a word). Maybe graphic design would be a better choice? It's not to late for me to change what I'm doing, I've mostly done generals.

  3. #18
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    The thing is I'm going into video game design, I was hoping to get into the design aspect and not the drudging through code.
    No game company is going to let you design without first proving yourself and drudging through the code. Design is something you do after you have been in the trenches for a bit and proven that you can find solutions to tough problems with minimal hand holding along the way.

    If you were designing something I was responsible for coding and you did not understand code well I would want off the project.

    You 'might' be able to sneak into project management without coding or knowledge of it since it really doesn't require it. However I seriously doubt that as well. Most of my PM's have coding experience even if they have forgotten most of it by now.

    I'm not saying it's 100% impossible to be in design without programming first nor am I saying that design always requires an understanding of implementation because it doesn't. I am saying it is highly improbable than any company in their right mind will let you design without programming for a bit first.
    Last edited by VirtualAce; 01-16-2009 at 05:28 PM.

  4. #19
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,765
    Also note that Java is not C++, and vice versa. If you are going to learn games, you should learn C++, and not think about Java, especially not it helping you out.
    This is harsh reality, but if you don't follow the course, then it's just better to quit, get a book, study yourself for sometime, and if necessary, re-apply when you can next.
    Members of this board will gladly help you out with self-studies if you get stuck.
    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
    Nov 2008
    Posts
    23
    That's exactly the conclusion I came to. I decided to take a break from college to figure out my strengths overall and go back with a fresh mind. I may or may not go with a career in graphic design because I do like to think up and make things. But as of right now, I'm just going to work and save up money. Darn student loans...

  6. #21
    Registered User
    Join Date
    Nov 2008
    Posts
    23
    Quote Originally Posted by Elysia View Post
    Then it's just better to quit, get a book, study yourself for sometime, and if necessary, re-apply when you can next.
    Members of this board will gladly help you out with self-studies if you get stuck.
    I will definately do this. Learning all there is about programming in one class doesn't seem right to me, now that I think about it. I just need to take my time.

  7. #22
    Registered User
    Join Date
    Nov 2008
    Posts
    23
    Alright. Here is the mostly completed assignment, with much help from a tutor and a little help from you guys.

    CTime.cpp:

    Code:
    /******************************
    * FILE: CTime.cpp
    * PROGRAMMER: Stephen Croy
    * DATE: 01-14-09
    *
    * Implementation of class CTime.
    *******************************/
    #include "CTime.h"
    
    using namespace std;
     
    
    CTime CTime::add(CTime t2)
    {
        //Declarations
        long t1Seconds;
        long t2Seconds;
        long t3Seconds;
        CTime answer;
        
        //Conversion of hours and minutes into seconds
        t1Seconds = ((long)hours)*3600 + minutes*60 + seconds;
        t2Seconds = ((long)t2.hours)*3600 + t2.minutes*60 + t2.seconds;
        t3Seconds = t1Seconds + t2Seconds;
        
        //Conversion of seconds back to hours and minutes
        answer.hours = t3Seconds / 3600;
        answer.minutes = t3Seconds % 3600 / 60;
        answer.seconds = t3Seconds % 3600 % 60;
        
        return answer;
    }
    CTime.h :

    Code:
    /******************************
    * FILE: CTime.h
    * PROGRAMMER: Stephen Croy
    * DATE: 01/14/09
    *
    * Declaration of class CTime.
    *******************************/
    #ifndef CTime_H
    #define CTime_H
        
    #include <iostream>
    
    
        class   CTime 
        {
        public:
               CTime();
               ~CTime()   {}       
               int getHours();
               int getMinutes();
               int getSeconds();
               CTime add(CTime);      
               void setHours(int);
               void setMinutes(int);
               void setSeconds(int);
               
               
        private:
                int hours;
                int minutes;
                int seconds;
        };
        
        inline CTime::CTime()
        {
               hours = 0;
               minutes = 0;
               seconds = 0;
               }
        
        inline int CTime::getHours()
        {      return hours;         }
        inline int CTime::getMinutes()
        {      return minutes;        }
        inline int CTime::getSeconds()
        {      return seconds;        }
        inline void CTime::setHours(int hr)
        {      hours = hr;              }
        inline void CTime::setMinutes(int min)
        {      minutes = min;             }
        inline void CTime::setSeconds(int sec)
        {      seconds = sec;             }
        
        #endif
    and TimeApp.cpp :

    Code:
    #include <cstdlib>
    #include <iostream>
    #include "CTime.h"
    
    using namespace std;
    
    int main(int argc, char *argv[])
    {
        char colon;
        int hrs;
        int mins;
        int secs;
        
        CTime firstT;
        CTime secondT;
        CTime answerT;
        
        cout << "Enter the first time in the format of HH:MM:SS\n\n";
        cin >> hrs >> colon >> mins >> colon >> secs;
        firstT.setHours(hrs);
        firstT.setMinutes(mins);
        firstT.setSeconds(secs);
        
        cout << "Enter the second time in the same format\n\n";
        cin >> hrs >> colon >> mins >> colon >> secs;
        secondT.setHours(hrs);
        secondT.setMinutes(mins);
        secondT.setSeconds(secs);
        
        answerT = firstT.add(secondT);
        cout << answerT.getHours();
        cout << answerT.getMinutes();
        cout << answerT.getSeconds();
         
        
        system("PAUSE");
        return EXIT_SUCCESS;
    }
    Now there is a problem when I go to compile. I get this error 4 times in a row with no reference to the line number:

    [Linker error] undefined reference to `CTime::CTime()'


    Thank you again for all the help guys.

  8. #23
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,332
    *shrug*

    You have '~CTime' defined but not 'CTime'.

    Soma

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you Initialize all classes once with New?
    By peacerosetx in forum C++ Programming
    Replies: 12
    Last Post: 07-02-2008, 10:47 AM
  2. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  3. Exporting VC++ classes for use with VB
    By Helix in forum Windows Programming
    Replies: 2
    Last Post: 12-29-2003, 04:38 PM
  4. Prime Number Generator... Help !?!!
    By Halo in forum C++ Programming
    Replies: 9
    Last Post: 10-20-2003, 07:26 PM
  5. include question
    By Wanted420 in forum C++ Programming
    Replies: 8
    Last Post: 10-17-2003, 03:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21