|
How are you using it in the other class?
Class A
{
public:
void AFunc();
}
Class B
{
void SomeBFunc();
}
void B::SomeBFunc()
{
A aInst;
aInst.AFunc();
AFunc();
}
Unless B is inherited from A.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
// creatfoufou.cpp: implementation of the creatfoufou class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "OpenGl.h"
#include "creatfoufou.h"
#include "foufou.h"
#include
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
creatfoufou::creatfoufou()
{
}
creatfoufou::~creatfoufou()
{
}
void creatfoufou::creatfou(int amount)
{
foufou *newfoufouPtr;
int randomX,randomY,randomZ;
int speed,steer;
for(int index=0;index {
newfoufouPtr = new foufou();
fou_caracter.push_back( newfoufouPtr );
//ici vien l'integration ou le dessin de foufou dans la scene
randomX = ( ( 1 + rand( ) % 900 ) - 450 );
randomY = ( ( 1 + rand( ) % 100 ) - 50 );
randomZ = ( ( 1 + rand( ) % 900 ) - 450 );
setposition(randomX,randomY,randomZ);
//speed =
//steer =
//lui attribue sa vitesse
//lui attribuer son emplacement
//lui attribuer sa direction
}
}
void creatfoufou::setposition(int newX, int newY, int newZ)
{
-->the mistak RePaint(randomX,randomY,randomZ);
}
and here when i declared
// foufou.cpp: implementation of the foufou class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "OpenGl.h"
#include "foufou.h"
#include
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
foufou::foufou()
{
}
foufou::~foufou()
{
}
//Propriétés réflectives de l'objet touché par la lumière
GLfloat Material_Ambiante[]={0.5,0.5, 0.5, 1 };
GLfloat Material_Difuse[]={0.5, 0.5, 0.5, 1};
GLfloat Material_Specular[]={0.5, 0.5, 0.5, 1};
//Propriété de la lumière
GLfloat Light_Ambiante[]={0.2, 0.2, 0.2, 0.1};
GLfloat Light_Difuse[]={0.5, 0.5, 0.5, 1.0 };
GLfloat Light_Specular[]={1.0, 1.0, 1.1, 1.0 };
GLfloat Light_Position[]={10, 12, 10, 1.0 };
GLfloat Light_Direction[]={0.0,-1.0, 0.0, 1.0};
void foufou::Initial()
{
//Définir les propriété de l'objet touché par la lumière ainsi que la lumière
glMaterialfv( GL_FRONT, GL_AMBIENT, Material_Ambiante);
glMaterialfv( GL_FRONT, GL_DIFFUSE, Material_Difuse);
glMaterialfv( GL_FRONT, GL_SPECULAR,Material_Specular);
glMaterialf( GL_FRONT, GL_SHININESS, 20);
glLightfv( GL_LIGHT0, GL_AMBIENT,Light_Ambiante );
glLightfv( GL_LIGHT0, GL_DIFFUSE, Light_Difuse );
glLightfv( GL_LIGHT0, GL_SPECULAR, Light_Specular);
glLightfv( GL_LIGHT0, GL_POSITION, Light_Position );
//Activation de l'éclairage
glEnable( GL_LIGHTING );
//Activation de la première lumière
glEnable( GL_LIGHT0 );
//Activation du test de profondeur
glEnable( GL_DEPTH_TEST );
};
void foufou::RePaint(int xpos,int ypos,int zpos)
{
//Vidage du contenu situé à l'écran
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//glClearColor(0.3, 0.3, 0.3, 1.0);
//On réénitialise la matrice modélisation-visualisation
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
//On place la caméra dans la scène
gluPerspective (90, 1, 5, 50);
gluLookAt (2,2, -15, -4,0.0, 1, 0.0, 1.0, 0.0 );
//surface avec rotation de 45°
glPushMatrix();
//rotation de la surface
// glTranslated(0.0, 30.0, 15.0 );
// glRotated( 15, 0.0, 0.0, 0.0 );
////////
//Proprité de réfléction ambiante de la matière
glColorMaterial( GL_FRONT, GL_AMBIENT );
glColor4f(0.5, 0.5, 0.6, 1.0 );
//Proprité de réfléction diffuse de la matière}
glColorMaterial( GL_FRONT, GL_DIFFUSE );
glColor4f( 0.5, 0.2, 0.8, 1.0 );
//Proprité de réfléction speculaire de la matière}
glColorMaterial( GL_FRONT, GL_SPECULAR );
glColor4f( 0.9, 0.8, 1.0, 1.0 );
//Création de la surface 30 x 30}
//glutSolidCube(3);
glTranslated(-xpos, ypos, zpos );
glutSolidSphere(0.9,30,40);
glDisable( GL_LIGHTING );
glPopMatrix();
//glDisable(GL_TEXTURE_2D);
SwapBuffers(wglGetCurrentDC());
};
|
|
|
|
|
aguest wrote:
void creatfoufou::setposition(int newX, int newY, int newZ)
{
-->the mistak RePaint(randomX,randomY,randomZ);
}
aguest wrote:
void foufou::RePaint(int xpos,int ypos,int zpos)
This is exactly what I stated in my previous message. Even though you declared RePaint as a public function in foufou class you can't just use it in createfoufou. You need to call it this way:
class createfoufou
{
public:
createfoufou()
private:
foufou *newfoufouPtr;
};
createfoufou::createfoufou()
{
newfoufouPtr = new foufou;
};
void creatfoufou::setposition(int newX, int newY, int newZ)
{
newfoufouPtr->RePaint(randomX,randomY,randomZ);
}
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
when i must declare
<br />
void B::SomeBFunc(){ A aInst; aInst.AFunc();
in which class or file(.h or .cpp)
|
|
|
|
|
In createfoufou.cpp
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
i make all what u ask me ,and this mistake don't stille but other mistakes appears:
<br />
OpenGlView.obj : error LNK2005: "int PANIC_SPEED" (?PANIC_SPEED@@3HA) already defined in creatfoufou.obj<br />
OpenGlView.obj : error LNK2005: "int MINIMUM_SPEED" (?MINIMUM_SPEED@@3HA) already defined in creatfoufou.obj<br />
OpenGlView.obj : error LNK2005: "int STARTINGSPEED" (?STARTINGSPEED@@3HA) already defined in creatfoufou.obj<br />
OpenGlView.obj : error LNK2005: "class std::vector<class foufou *,class std::allocator<class foufou *> > fou_caracter" (?fou_caracter@@3V?$vector@PAVfoufou@@V?$allocator@PAVfoufou@@@std@@@std@@A) already defined in creatfoufou.obj<br />
OpenGlView.obj : error LNK2005: "int num_fou_caracter" (?num_fou_caracter@@3HA) already defined in creatfoufou.obj<br />
Debug/OpenGl.exe : fatal error LNK1169: one or more multiply defined symbols found<br />
Error executing link.exe.<br />
Creating browse info file...<br />
<br />
OpenGl.exe - 6 error(s), 2 warning(s)<br />
this
<br />
#if !defined(AFX_CREATFOUFOU_H__BE7E5BDB_1815_48E7_AAC4_B30A8F281BA4__INCLUDED_)<br />
#define AFX_CREATFOUFOU_H__BE7E5BDB_1815_48E7_AAC4_B30A8F281BA4__INCLUDED_<br />
<br />
<br />
<br />
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif // _MSC_VER > 1000<br />
#include "gl/glut.h"<br />
#include "foufou.h"<br />
#include <vector> <br />
<br />
int STARTINGSPEED = 150;<br />
int MINIMUM_SPEED =80;<br />
int PANIC_SPEED =25;<br />
<br />
using namespace std;<br />
vector< foufou * > fou_caracter;<br />
int num_fou_caracter;<br />
<br />
class creatfoufou <br />
{<br />
<br />
<br />
public:<br />
GLfloat randomZ;<br />
GLfloat randomY;<br />
GLfloat randomX;<br />
void setposition(int newX,int newY,int newZ);<br />
void creatfou(int amount);<br />
<br />
creatfoufou();<br />
virtual ~creatfoufou();<br />
private:<br />
foufou *ptrfoufou;<br />
<br />
};<br />
<br />
#endif // !defined(AFX_CREATFOUFOU_H__BE7E5BDB_1815_48E7_AAC4_B30A8F281BA4__INCLUDED_)<br />
|
|
|
|
|
I am not sure but my best guess is that these variables:
int STARTINGSPEED = 150;
int MINIMUM_SPEED =80;
int PANIC_SPEED =25;
using namespace std;
vector< foufou * > fou_caracter;
int num_fou_caracter;
have been declared somewhere else. Maybe in creatfoufou.cpp or foufou.h.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
Is there a way to print out a warning when someone goes to use a function? I want it to be printed whenever (and only when) the function is referenced.
-Jack
There are 10 types of people in this world, those that understand binary and those who don't.
|
|
|
|
|
VC7 Specific
#pragma deprecated( function1 [, function2, ...] )
-OR-
__declspec(deprecated) void func1(int)
{
printf("In func2\n");
}
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Tim Smith wrote:
__declspec(deprecated) void func1(int)
{
printf("In func2\n");
}
This seems to not work in g++ but thanks for putting me on the right track.
-Jack
There are 10 types of people in this world, those that understand binary and those who don't.
|
|
|
|
|
Anything starting with two underscores is compiler specific.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
<br />
#include "stdafx.h"<br />
#include "OpenGl.h"<br />
#include "creatfoufou.h"<br />
#include "foufou.h"<br />
<br />
#include <math.h><br />
<br />
#ifdef _DEBUG<br />
#undef THIS_FILE<br />
static char THIS_FILE[]=__FILE__;<br />
#define new DEBUG_NEW<br />
#endif<br />
<br />
<br />
creatfoufou::creatfoufou()<br />
{<br />
<br />
}<br />
<br />
creatfoufou::~creatfoufou()<br />
{<br />
<br />
}<br />
<br />
void creatfoufou::creatfou(int amount)<br />
{<br />
foufou *newfoufouPtr;<br />
int randomX,randomY,randomZ;<br />
int speed,steer;<br />
<br />
for(int index=0;index<amount;index++)<br />
{<br />
newfoufouPtr = new foufou();<br />
fou_caracter.push_back( newfoufouPtr );<br />
randomX = ( ( 1 + rand( ) % 900 ) - 450 );<br />
randomY = ( ( 1 + rand( ) % 100 ) - 50 );<br />
randomZ = ( ( 1 + rand( ) % 900 ) - 450 );<br />
<br />
setposition(randomX,randomY,randomZ);<br />
<br />
<br />
<br />
}<br />
}<br />
<br />
void creatfoufou::setposition(int newX, int newY, int newZ)<br />
{<br />
-->the mistak RePaint(randomX,randomY,randomZ);<br />
}<br />
and here when i declared
<br />
#include "stdafx.h"<br />
#include "OpenGl.h"<br />
#include "foufou.h"<br />
#include <gl/glut.h><br />
<br />
#ifdef _DEBUG<br />
#undef THIS_FILE<br />
static char THIS_FILE[]=__FILE__;<br />
#define new DEBUG_NEW<br />
#endif<br />
<br />
<br />
foufou::foufou()<br />
{<br />
<br />
}<br />
<br />
foufou::~foufou()<br />
{<br />
<br />
}<br />
<br />
<br />
<br />
GLfloat Material_Ambiante[]={0.5,0.5, 0.5, 1 };<br />
GLfloat Material_Difuse[]={0.5, 0.5, 0.5, 1};<br />
GLfloat Material_Specular[]={0.5, 0.5, 0.5, 1};<br />
<br />
<br />
<br />
<br />
GLfloat Light_Ambiante[]={0.2, 0.2, 0.2, 0.1};<br />
GLfloat Light_Difuse[]={0.5, 0.5, 0.5, 1.0 };<br />
GLfloat Light_Specular[]={1.0, 1.0, 1.1, 1.0 };<br />
GLfloat Light_Position[]={10, 12, 10, 1.0 };<br />
<br />
<br />
<br />
GLfloat Light_Direction[]={0.0,-1.0, 0.0, 1.0};<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
void foufou::Initial()<br />
{<br />
<br />
glMaterialfv( GL_FRONT, GL_AMBIENT, Material_Ambiante);<br />
glMaterialfv( GL_FRONT, GL_DIFFUSE, Material_Difuse);<br />
glMaterialfv( GL_FRONT, GL_SPECULAR,Material_Specular);<br />
glMaterialf( GL_FRONT, GL_SHININESS, 20);<br />
<br />
glLightfv( GL_LIGHT0, GL_AMBIENT,Light_Ambiante );<br />
glLightfv( GL_LIGHT0, GL_DIFFUSE, Light_Difuse );<br />
glLightfv( GL_LIGHT0, GL_SPECULAR, Light_Specular);<br />
glLightfv( GL_LIGHT0, GL_POSITION, Light_Position );<br />
<br />
<br />
<br />
<br />
glEnable( GL_LIGHTING );<br />
<br />
<br />
glEnable( GL_LIGHT0 );<br />
<br />
<br />
<br />
glEnable( GL_DEPTH_TEST );<br />
<br />
};<br />
<br />
void foufou::RePaint(int xpos,int ypos,int zpos)<br />
{<br />
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);<br />
<br />
<br />
glMatrixMode (GL_PROJECTION);<br />
glLoadIdentity ();<br />
<br />
<br />
<br />
gluPerspective (90, 1, 5, 50);<br />
gluLookAt (2,2, -15, -4,0.0, 1, 0.0, 1.0, 0.0 );<br />
<br />
<br />
glPushMatrix();<br />
<br />
<br />
<br />
glColorMaterial( GL_FRONT, GL_AMBIENT );<br />
glColor4f(0.5, 0.5, 0.6, 1.0 );<br />
glColorMaterial( GL_FRONT, GL_DIFFUSE );<br />
glColor4f( 0.5, 0.2, 0.8, 1.0 );<br />
glColorMaterial( GL_FRONT, GL_SPECULAR );<br />
glColor4f( 0.9, 0.8, 1.0, 1.0 );<br />
<br />
<br />
<br />
glTranslated(-xpos, ypos, zpos );<br />
glutSolidSphere(0.9,30,40);<br />
glDisable( GL_LIGHTING );<br />
<br />
glPopMatrix();<br />
<br />
<br />
<br />
<br />
<br />
SwapBuffers(wglGetCurrentDC());<br />
<br />
};<br />
|
|
|
|
|
Did this have anything to do with my thread? If so I can't see how.
-Jack
There are 10 types of people in this world, those that understand binary and those who don't.
|
|
|
|
|
Is there anyway to have a class defined within a namespace, and still use a forward declaration? Take the following example:
class myclass;
static void function(myclass *p);
namespace abc
{
class myclass
{
public:
int i;
};
};
using abc::myclass;
Compiling this with VC++ 6.0, I get error "C2874: using-declaration causes a multiple declaration of 'myclass'". Is there anyway around this? Does using namespaces mean you can no longer use forward declarations?
Thanks for your help.
|
|
|
|
|
You have to declare it like this
namespace abc
{
class myclass;
}
|
|
|
|
|
I have this dialog based project with a huge set of menus that I need to duplicate in my SDI. Can I just import them? If so how?????
|
|
|
|
|
with the SDI project open, open the dialog project's .RC file. Copy the menu ID's and paste them into your SDI project's resource window. Simple copy and paste.
|
|
|
|
|
Much obliged pardner!
|
|
|
|
|
I have an application that is sending data through a serial port. That is working fine, but I am now to the point where I need to read from the serial port. I same across a CSerial Class developed by P J Naughter and it works quite well. I have played around with the Read() function and it works as long as you call it when you know something has already hit the port.
The application I am using this in is just a very simple dialog application. How do I setup an event handler that can interupt my program when a byte has hit the serial port? I have looked at some various resources without success. Does anyone have an idea that could help?
Thanks
Kevin Shaffer
Student of Computer Science
University of Kansas
kshaff03@msn.com
|
|
|
|
|
One solution is to implement a non-blocking I/O model to communicate with the port. Microsoft published one solution using OVERLAPPED I/O.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp
Kuphryn
|
|
|
|
|
I've already spent alot of time in this article, but it doesnt help me (or at least I don't understand it well enough to help me). My application is running on a pc, and it needs to recieve instructions from a Palm, fetch data from the pc, and send it back to the Palm.
In order to do this, my application needs to be sitting here, and realize, oh! something has just hit the serial port. The program reads the data and processes it, then waits for the next com port "Event". I would prefer not to create my own loop and continue to poll the serial port, because then my application cannot handle other events that might occur.
That artice mentions an event called EV_RXCHAR is issued when a byte hits the serial port. I went through the message handling tutorials and tried to set up an event handler using ON_MESSAGE with no success. Im still trying all sorts of things, any more input would be appreciated.
thanks!
Kevin Shaffer
Student of Computer Science
University of Kansas
kshaff03@msn.com
|
|
|
|
|
I have worked on a similar project 3 years ago and one of my team members handled the incoming data so I really don't remember much about the topic. If I remember correctly you have to have a thread which checks the serial port for a "Receive Character Event" and a while statement calling WaitCommEvent. I don't remember much but I hope that helps you.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
Do as the sample \Microsoft Visual Studio\MSDN98\SAMPLES\VC98\SDK\WINBASE\IO\SERIAL do,all things are OKAY
QQ
|
|
|
|
|
Hello!
I have exactly the same Problem!
I just created a small function that results the current fill-status of the serial buffer. I used the implemented GetModemStatus function of CSerial from P.J.Naughter.
e.g.:
if (SomethingInIt()==TRUE)
buffer = Port.Read(..);
So this is nonblocking.
I hope I help you out!
Greetings from germany, Jan
|
|
|
|
|
I have a program that uses a Progress bar , but when i try to minimise the dialog window during execution or activate some other program ,
and then return back to the dialog seems to get freezed
, progress bar status does not increment ,
HOWEVER the program run correctly in the background and after its execution completes the dialog freeze end and it is displayed currectly .
Any suggestions ??
|
|
|
|
|