Shadow Blade
Morrowland Presents Apron Tutorials
game - design - multimedia - web - programming - tutorials - There are currently viewers visiting Apron Tutorials.
   
 
TECHNICAL
GRAPHICAL
SOUND
GAME
WEB
ARTICLE
TOOL
PROJECT
 
 NEWS

  news

  history


 TECHNICAL TUTORIALS

  opengl

  direct3d

  c/c++

  visual basic

  java

  c#


 WEB TUTORIALS

  html

  dhtml

  asp

  php


 IMAGE EDITING

  photoshop

  draw sketch


 3D MODELING

  3d studio


 PROJECTS

  shadow blade

  game environment

  virtual 3d guide

  billy blue flame


 DEMOS

  win32 api


 ARTICLES

  general

  opengl


 COMMUNITY

  about us

  credit

  contact












#ifndef _MYHEADER_H	
#define _MYHEADER_H	


#include <stdio.h> // include our extern header files here
#include <iostream>		
using namespace std;


struct tMyStruct // declare a new struct
{
	int	id;
	char	grade;
	bool	active;
};


#endif



#include "myheader.h" // include our header file

int main()				
{	
	tMyStruct player;

	player.id = 10;
	player.active = true;
	player.grade = 'a';

	cout << player.id << " " << player.active << " " << player.grade;

	getchar(); // wait until a key is pressed
	return 0;
}


/*

Learn how to use a Struct to ease and systemize your programming.
A structure type is a user-defined composite type. It is composed of fields or
members that can have different types. In C++, a structure is the same as a
class except that its members are public by default.(I will explain class
in the next tutorial)


Its form is the following: 


struct struct_type_name
{
  type1 member1;
  type2 member2;
  type3 member3;
  .
  .
};

or

It's form can also be like this:

struct model_name{
  type1 element1;
  type2 element2;
  type3 element3;
  .
  .
} object_name;


where model_name is a name for the model of the structure type and the
optional parameter object_name is a valid identifier (or identifiers) for
structure object instantiations. Within curly brackets { } they are the
types and their sub-identifiers corresponding to the elements that compose
the structure. 


After you have declared your struct:

struct tMyStruct		// declare tMyStruct struct type
{
	int	id;	// declare member types
	char	grade;
	bool	active;
};

You can use your struct like this:
Declare a variable containing all the members/elements of your struct.

tMyStruct myVariable;	// declare our new variable


myVariable will now contain all the members in the struct.
Example of use:

int id		= myVariable.id;
char grade	= myVariable.grade;
bool active	= myVariable.active;

*/



Download The Source Code! Download Visual C++ Source Code


I hope you found this c++ tutorial useful!

Don't forget to mention Apron Tutorials in your References!

Best Regards
Ronny André Reierstad

 LINKS

  morrowland home



 GAME DEVELOPEMENT

  nvidia

  gamedev

  polycount


 PROJECTS

  shadow blade

  game environment

  virtual 3d guide

  billy blue flame


 MATH AND PHYSICS

  mathworld

  physicsworld







PLEASE LINK TO


  All rights reserved Morrowland © 2011  
Ronny André Reierstad