Difference between revisions of "Using SimpleObject Class"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Created page with "Now we have a class for a simple object (SimpleObj) we can use it. This will create a class for your game, and it will create objects of the SimpleObj class.")
 
Line 1: Line 1:
 
Now we have a class for a simple object (SimpleObj) we can use it. This will create a class for your game, and it will create objects of the SimpleObj class.
 
Now we have a class for a simple object (SimpleObj) we can use it. This will create a class for your game, and it will create objects of the SimpleObj class.
 +
 +
==Game.h==
 +
 +
Remember a class in C++ needs a header to declare the variables and to specify the methods it contains. Remember it provides no implementation for the methods:
 +
 +
<syntaxhighlight lang=c++>
 +
#pragma once
 +
 +
class Game
 +
{
 +
public:
 +
Game(); //standard constructor
 +
~Game(); //standard destructor
 +
 +
//list the functions we want to have (called methods in C++)
 +
void Update();
 +
};
 +
</syntaxhighlight>

Revision as of 08:33, 13 June 2019

Now we have a class for a simple object (SimpleObj) we can use it. This will create a class for your game, and it will create objects of the SimpleObj class.

Game.h

Remember a class in C++ needs a header to declare the variables and to specify the methods it contains. Remember it provides no implementation for the methods:

#pragma once

class Game
{
public:
	Game(); //standard constructor
	~Game(); //standard destructor

		//list the functions we want to have (called methods in C++)	
	void Update();
};