compiler error

This is a discussion on compiler error within the C++ Programming forums, part of the General Programming Boards category; Hi, i created a header file and its .cpp file with the method definitons. On compile it gives me errors ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    134

    compiler error

    Hi, i created a header file and its .cpp file with the method definitons. On compile it gives me errors abt the declaration of increment, even though it is set to void

    link to assignment:- http://www.cs.uh.edu/~svenkat/lib/as...r2003/ASSIGN1/

    this is header file
    Code:
    class ModuloCounter //name of class
    {
    public:
    	ModuloCounter(int); //the constructor, will take mod value given by user
    	~ModuloCounter();//destructor, which will also take care of the number of counters
    	int getCounterValue();//returns counter value
    	int getCounterLimit();//returns counter limit
        int getNumberofModuloCounters();//returns number of counters running
    	void increment();//increase counter value 
    	void decrement();//decreases counter value
    
    private:
    	int counterLim;//this is the mod limit set by the user
    	int counterVal;//counter value from 1 to counterLim
    	int moduloNum;//number of counters running
    
    
    
    };//end of class

    and here is the .cpp file
    Code:
    #include "ModuloCounter.h"
    
    ModuloCounter::ModuloCounter(int set)
    {
    	counterLim=set;
    	moduloNum++;
    };
    
    ModuloCounter::~ModuloCounter()
    {
    	moduloNum--;
    }
    
    ModuloCounter::getCounterLimit()
    {
    	return counterLim;
    }
    
    ModuloCounter::getCounterValue()
    {
    	return counterVal;
    }
    
    ModuloCounter::getNumberofModuloCounters()
    {
    	return moduloNum;
    }
    
    ModuloCounter::increment()
    {
    	if(counterVal==counterLim)counterVal=1;
    
    	else
    	{
    		counterVal++;
    	}
    }
    
    ModuloCounter::decrement()
    {
    	if(counterVal==1)counterVal=counterLim;
    	else
    	{
    		counterVal--;
    	}
    }

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Need return types in your .cpp file.

    i.e.
    Code:
    int ModuloCounter::getCounterValue()
    {
    	return counterVal;
    }
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    134
    thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 03:35 PM
  2. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  3. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  4. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 09:43 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

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