Click here to Skip to main content
15,888,984 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionProblem with CreateFileMapping() window7/Vista. Pin
janaswamy uday17-May-10 19:41
janaswamy uday17-May-10 19:41 
AnswerRe: Problem with CreateFileMapping() window7/Vista. Pin
hanq_3891013017-May-10 20:59
hanq_3891013017-May-10 20:59 
AnswerRe: Problem with CreateFileMapping() window7/Vista. Pin
Richard MacCutchan17-May-10 21:37
mveRichard MacCutchan17-May-10 21:37 
Questionaudio chat Pin
69917-May-10 17:24
69917-May-10 17:24 
AnswerRe: audio chat Pin
Stephen Hewitt17-May-10 17:33
Stephen Hewitt17-May-10 17:33 
AnswerRe: audio chat Pin
Cedric Moonen17-May-10 20:20
Cedric Moonen17-May-10 20:20 
AnswerRe: audio chat Pin
CPallini17-May-10 23:23
mveCPallini17-May-10 23:23 
QuestionVisual Studio C++ Object Oriented Pin
RobNO17-May-10 12:26
professionalRobNO17-May-10 12:26 
Hey Everyone. I have been having linking problem with visual studio. My Problem basically is I do not know how to set it up. What I have been doing is just making one ".hpp" file with multiple classes/preprocessors in it and separate ".cpp" files for the classes and a test file, but I have a strong suspicion this is not the way one is suppose to do this. Maybe I am just going about it wrong as well, here is the latest inheritance I have been working on and cannot seems to get working.
this files called: geo.hpp
//inherit/coord.hpp
#ifndef COORD_HPP
#define COORD_HPP

//header file for i/o
#include <iostream>

namespace Geo		//*****BEGIN namespace Geo*****
{
	
	/*class Coord
	 *- auxiliary class for geometric objects
	 *- not suitable for inheritance
	 */
	class Coord
	{
	private:
		int x;		//X coordinate
		int y;		//Y coordinate
	
	public:
		//default constructor, and two-paramter constructor
		Coord() : x(0), y(0)		//default values:0
		{
		}
		Coord(int newx, int newy) : x(newx), y(newy)
		{
		}

		Coord operator + (const Coord&) const;		//addition
		Coord operator - () const;					//negative
		void operator += (const Coord&);			//addition assignment
		void printOn(std::ostream& strm) const;		//output
	};

	/*operator +
	 *- add X and Y coordinates
	 */
	inline Coord Coord::operator + (const Coord& p) const
	{
		return Coord(x+p.x, y+p.y);
	}

	/*unary operator
	 *- negative X and Y coordinates
	 */
	inline Coord Coord::operator -() const
	{
		return Coord(-x, -y);
	}
	/*operator +=
	 *- output coordinates as a pair of values
	 */
	inline void Coord::printOn(std::ostream& strm) const
	{
		strm << '(' << x << ',' << y << ')';
	}

	/*operator <<
	 *- conversion for standard output operator
	 */
	inline std::ostream& operator << (std::ostream& strm, const Coord& p)
	{
		p.printOn(strm);
		return strm;
	}

}			//*****END namespace Geo*****

#endif		//COORD_HPP

//inherit/geoobj.hpp
#ifndef	GEOOBJ_HPP		
#define GEOOBJ_HPP

//header file for coordinates
#include "geo.hpp"

namespace Geo
{
	/*abstract base class GeoObj
	 *	- common base class for geometric objects
	 *	- provided for inheritance
	 */
	
	class GeoObj
	{
	protected:
		//every GeoObj has a reference point
		Coord refpoint;

		/*constructor for an initial reference point
		 *	- not public
		 *	- there is no default constructor available
		 */

		GeoObj(const Coord& p) : refpoint(p)
		{
		}

	public:
		//move geometric object according to passes relative offset
		virtual void move(const Coord& offset)
		{
			refpoint += offset;
		}

		/*draw geometric object
		 *	- pure virtual function
		 */
		virtual void draw() const = 0;

		//virtual destructor
		virtual ~GeoObj()
		{
		}
	};
}	//*****END namesapce Geo*****

#endif		//GEOOBJ_HPP

//inherit/circle.hpp
#ifndef CIRCLE_HPP
#define CIRCLE_HPP

//haderfile for Input and output
#include <iostream>

//include header file for the base class geoobj.hpp
#include "geo.hpp"

namespace Geo
{
	/*class Circle
	 *	- Derived from GeoObj
	 *	- A circle consists of:
	 *		- a center point (reference point, inherited)
	 *		- a radius (new)
	 */
	class Circle : public GeoObj
	{
	protected:
		unsigned radius;		//radius

	public:
		//constructor for center point and radius
		Circle(const Coord& m, unsigned r)
			: GeoObj (m), radius(r)
		{

		}

		//draw geometric object (now implemented)
		virtual void draw() const;

		//virtual destructor
		virtual ~Circle()
		{

		}
	};

	/*drawing
	 *	- defined inline
	 */
	inline void Circle::draw() const
	{
		std::cout << "Circle around center point " << refpoint << " with radius " << radius << std::endl;
	}
}		//*****END namespace Geo*****
#endif	//end CIRCLE_HPP	

//inherit/line.hpp
#ifndef LINE_HPP
#define LINE_HPP

//header file for I/O
#include <iostream>

//header file of the base class
#include "geo.hpp"

namespace Geo
{
	/*class Line
	 *	-Derived from GeoObj
	 *	-A line consists of:
	 *		-a start point (refernce point, inherited)
	 *		-an end point (new)
	 */
	class Line : public GeoObj
	{
	protected:
		Coord p2;		//second point, end point

	public:
		//constructor for start and end points
		Line(const Coord& a, const Coord& b)
			:GeoObj(a), p2(b)
		{
		}

		//draw geometric object (now implemented)
		virtual void draw() const;

		//move geometric object(reimplemented)
		virtual void move(const Coord&);

		//virtual destructor
		virtual ~Line()
		{
		}
	};
	/*output
	 *	-defined inline
	 */
	inline void Line::move(const Coord& offset)
	{
		refpoint += offset;		//represents GeoObj::move(offset);
		p2 += offset;
	}
}		//*****END namesapce Geo*****

#endif		//LINE_HPP


and a simple test file.
this file is called :test.cpp
//inherit/geotest1.cpp

//header file for used classes
#include "geo.hpp"

//forward declaration
void printGeoObj(const Geo::GeoObj&);

int main()
{
	Geo::Line l1(Geo::Coord(1,2), Geo::Coord(3,4));
}


So i hope someone can help me arrage these files properly with visual studio 9 c++, or help me figure out what I am doing wrongConfused | :confused:
Thanks alot!
AnswerRe: Visual Studio C++ Object Oriented Pin
chaau17-May-10 13:42
chaau17-May-10 13:42 
GeneralRe: Visual Studio C++ Object Oriented Pin
RobNO18-May-10 11:01
professionalRobNO18-May-10 11:01 
GeneralRe: Visual Studio C++ Object Oriented Pin
RobNO18-May-10 11:25
professionalRobNO18-May-10 11:25 
Questiondefine arrow keys in c Pin
hasani200717-May-10 10:23
hasani200717-May-10 10:23 
AnswerRe: define arrow keys in c Pin
Richard MacCutchan17-May-10 10:25
mveRichard MacCutchan17-May-10 10:25 
AnswerRe: define arrow keys in c Pin
David Crow17-May-10 10:28
David Crow17-May-10 10:28 
AnswerRe: kbhit() Pin
Software_Developer17-May-10 11:03
Software_Developer17-May-10 11:03 
QuestionChange the colour in c Pin
hasani200717-May-10 10:18
hasani200717-May-10 10:18 
AnswerRe: Change the colour in c Pin
Richard MacCutchan17-May-10 10:25
mveRichard MacCutchan17-May-10 10:25 
AnswerRe: Change the colour in c Pin
David Crow17-May-10 10:25
David Crow17-May-10 10:25 
AnswerRe: Change the colour in c Pin
CPallini17-May-10 10:29
mveCPallini17-May-10 10:29 
Questionhow to get the walls from input? Pin
hasani200717-May-10 10:14
hasani200717-May-10 10:14 
AnswerRe: With cin? Pin
Software_Developer17-May-10 11:28
Software_Developer17-May-10 11:28 
QuestionChanging edit box font size Pin
pjdriverdude17-May-10 7:35
pjdriverdude17-May-10 7:35 
AnswerRe: Changing edit box font size Pin
David Crow17-May-10 8:13
David Crow17-May-10 8:13 
GeneralRe: Changing edit box font size Pin
pjdriverdude17-May-10 9:39
pjdriverdude17-May-10 9:39 
Questionhow to know the control? Pin
chikach17-May-10 7:12
chikach17-May-10 7:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.