|
Please post the code.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Here is the code.
#include "HelloWorld.h"
#include <dtCore/globals.h>
#include <dtCore/object.h>
#include <dtCore/orbitmotionmodel.h>
#include <dtCore/scene.h>
#include <osgDB/FileUtils>
#include <dtCore/dt.h>
#include <dtABC/application.h>
#include <dtCore/deltawin.h>
HelloWorld::HelloWorld(const std::string& configFilename):dtABC::Application(configFilename),mText(0),mOrbitMotionModel(0)
{
if(osgDB::findDataFile(configFilename).empty())
{
GenerateDefaultConfigFile();
}
}
HelloWorld::~HelloWorld()
{
}
void HelloWorld::Config()
{
mText = new dtCore::Object("Text");
mText->LoadFile("HelloWorld.flt");
GetScene()->AddDrawable( mText.get() );
dtCore:: Transform camPos;
camPos.SetLookAt( 0.0f, -100.0f, 20.0f,
0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f);
GetCamera()->SetTransform(camPos);
mOrbitMotionModel = new dtCore::OrbitMotionModel(GetKeyboard(),GetMouse());
mOrbitMotionModel->SetTarget(GetCamera());
}
int main()
{
dtCore::SetDataFilePathList( ".;" + dtCore::GetDeltaDataPathList());
dtCore::RefPtr<HelloWorld> app = new HelloWorld( "config.xml" );
app->Config();
app->Run();
return 0;
}
|
|
|
|
|
And the HelloWorld.h code?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
#include <dtABC/application.h>
#include <dtCore/refptr.h>
namespace dtCore
{
class Object;
class OrbitMotionModel;
}
class HelloWorld: public dtABC::Application
{
public:
HelloWorld(const std::string &configFilename);
protected:
virtual ~HelloWorld();
public:
virtual void Config();
private:
dtCore::RefPtr<dtCore::Object> mText;
dtCore::RefPtr<dtCore::OrbitMotionModel> mOrbitMotionModel;
}
|
|
|
|
|
Well, I cannot spot the error. The code seems OK.
Anyway, I insist, the right place for #include "HelloWorld.h" is at the bottom of the list.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
you're missing a ; after the closing } of the class definition.
a class definition is like this :
class C {
}<code>;</code>
|
|
|
|
|
Then it probably means you have errors in that file. Post some code (and please, use the code block tags).
|
|
|
|
|
Here is the complete listing.
#include "HelloWorld.h"
#include <dtCore/globals.h>
#include <dtCore/object.h>
#include <dtCore/orbitmotionmodel.h>
#include <dtCore/scene.h>
#include <osgDB/FileUtils>
#include <dtCore/dt.h>
#include <dtABC/application.h>
#include <dtCore/deltawin.h>
HelloWorld::HelloWorld(const std::string& configFilename):dtABC::Application(configFilename),mText(0),mOrbitMotionModel(0)
{
if(osgDB::findDataFile(configFilename).empty())
{
GenerateDefaultConfigFile();
}
}
HelloWorld::~HelloWorld()
{
}
void HelloWorld::Config()
{
mText = new dtCore::Object("Text");
mText->LoadFile("HelloWorld.flt");
GetScene()->AddDrawable( mText.get() );
dtCore:: Transform camPos;
camPos.SetLookAt( 0.0f, -100.0f, 20.0f,
0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f);
GetCamera()->SetTransform(camPos);
mOrbitMotionModel = new dtCore::OrbitMotionModel(GetKeyboard(),GetMouse());
mOrbitMotionModel->SetTarget(GetCamera());
}
int main()
{
dtCore::SetDataFilePathList( ".;" + dtCore::GetDeltaDataPathList());
dtCore::RefPtr<HelloWorld> app = new HelloWorld( "config.xml" );
app->Config();
app->Run();
return 0;
}
|
|
|
|
|
Where is line 29 at? That's the one that eventually caused the compiler to complain?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello all.
I have this code with something error occured:
//------------------------------------------
#include "iostream"
using namespace std;
class aa
{
public:
aa()
{
aa(5);
}
aa(int t)
{
x = t;
}
void print()
{
cout << x << endl;
}
private:
int x;
};
int main()
{
aa t;
t.print();//this can't output "5", why?
return 0;
}
///---------------------------
As is descriped above, thanks in advance!
If we dream, every thing is possible!
modified on Thursday, June 5, 2008 3:31 AM
|
|
|
|
|
Could you please elaborate the problem ? What's wrong ?
And please use the "code block" option when posting code (all of that is clearly explained in the posting guidelines).
|
|
|
|
|
(excluding << and >> operators usage!) He creates a temporary object (calling aa(5) ) inside the default constructor, probably he wanted to initialize x with 5 instead.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
and WHAT IS the error occuring dude ?!
BTW, i see a problem in your cout statements.
cout cannot use the >> operator. it uses << operator only, so change your code into this :
void print() {
cout << x << endl;
}
and everywhere you're doing such a mistake...
|
|
|
|
|
He creates a temporary object (calling aa(5) ) inside the default constructor (leaving garbage inside x ), probably he wanted to initialize x with 5 instead.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
thanks dear. but i saw your answer, so no need to flood the thread
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
toxcct wrote: so no need to flood the thread
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Oh what happend for your thread I give you 5 but I think it needs to repair.
|
|
|
|
|
Thanks my friend.
Anyway I don't bother if people don't appreciate my humour.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
You made a mistake in the default constructor. Can you spot it?
BTW: The correct method is
class aa
{
public:
aa():x(5)
{
}
};
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thank you Pallini.I got it...
But i found this code can't work.
class aa
{
public:
aa():x(5)
{ }//...
};
it said x(5) is not a base class.
Thanks once again!
If we dream, every thing is possible!
|
|
|
|
|
it's because in this class, you don't define a x member...
|
|
|
|
|
In my sample
was the concise notation for
aa(int t)
{
x = t;
}
void print()
{
cout << x << endl;
}
private:
int x;
};
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Is This program working ???
cout>>x>>endl;
cin<<ch;
try using debuging than you find that why x is not giving right output
#include "stdafx.h"
#include <iostream>
using namespace std;
class aa
{
public:
aa(int t = 5)
{
x = t;
}
void print()
{
cout<<x <<endl;
}
private:
int x;
};
int main(int argc, char* argv[])
{
aa t;
t.print();
cout<<"---------------------"<<endl;
aa t1(4);
t1.print();
char ch;
cin>>ch;
return 0;
}
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
modified on Thursday, June 5, 2008 3:41 AM
|
|
|
|
|
Shilpi Boosar wrote: cout>>x>>endl;cin<<ch;
you're not serious, are you ?
when you don't know what you're talking about, please avoid posting crap, that will avoid the question poster to be confused at last.
|
|
|
|
|
Sorry toxcct.It's my fault.
I have edited my post.
Thanks youtoxcct.
If we dream, every thing is possible!
|
|
|
|