Originally posted by chanuajohnson
how do i create a class called Largest thatworks with only unsigned long values with the following methods(functions)
Largest()
bool getnext()
unsigned long value()const
i need help how to begin
i need
Largest.h
Largest.cpp
and largestDriver.cpp()
to be included as my files
also how do i protect Largest.h from the mulitple inclusion with the #pragma once tag.
Don't use #pragma once it is compiler specific. Here is what your H file might look like, keep in mind you will have to write the function implementation in the accompanying cpp file.
Code:
#ifndef LARGEST_H
#define LARGEST_H
class Largest
{
private:
unsigned long m_foo;
unsigned long m_foo2;
public:
Largest( ); // Constructor
~Largest( ); // Destructor
bool getNext( );
unsigned long value( ) const;
};
#endif /* LARGEST_H */
Use those #ifndef's for inclusion guards instead of #pragma once. Post back if you have more questions.
OOPS: To create an instance of this class in your main code, simply use the following syntax.
Largest MyLargeList;
Where Largest is the class you want to create an instance of and MyLargeList is the variable name.