COORD in a class

Started by
2 comments, last by demonkoryu 19 years, 6 months ago
Ok... im writing a small program IN C++ USING msc++ to get classes down better. The program will be in a dos window (eg. console app.), and am using the "SetConsoleCursorPosition()" FUNCTION, WHICH REQURES A coord. I am wondering if it is possible to create a COORD as a class member variable? So far all of my attaemps have failed.
Advertisement
Yes, possible.
Code & error messages-p?

Thermo
I took out everyhting but the coord for this:

#include <iostream.h>
#include <stdlib.h>

class mammal
{
public:
mammal(){}
virtual ~mammal(){}

virtual void setX(int x) {c.X = x;}
virtual void setY(int y) {c.Y = y;}

private:
COORD c;
};


errors:

error C2146: syntax error : missing ';' before identifier 'c'
error C2501: 'COORD' : missing storage-class or type specifiers
error C2501: 'c' : missing storage-class or type specifiers
ok.

The error is, you forgot to include <windows.h>

The other thing is, better use <cstdlib> & <iostream> instead of the .h headers, because these are deprecated.

Thermo

This topic is closed to new replies.

Advertisement