|
Rajesh R Subramanian wrote: What in the world does C++ have to do with that code?
Perhaps the C++ compiler, once overwent its perplexities, will try to compile it.
(Just kidding).
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
|
|
|
|
|
1) this is C
2) this code is for Borland compiler, and you are you a Visual C++ forum
3) please use the <pre></pre> tags (not <code> )to format your code samples
4) post relevant pieces of code, not a huge entiere source file
5) Read the posting Guidelines at the beginning of this forum
6) what's you question actually ?
|
|
|
|
|
I really think nobody will seriously answer to you if you don't cricubscribe your problem.
No one will read tens of noob code...
If you want to create a trivia-program, the best solution is collect questions and their respective
answers on a text file, than create a more structured engine that reads them and determines if
answers are right or not.
You can't improve randomization untill you have a more efficient question-selection engine.
Didn't you mean to compile your code avery time you add a new question ?
Remember, never post long code chunks if not necessary... time is worthy 4..
bye
|
|
|
|
|
You need a structure of some sort to hold:
The question
The list of possible answers
The correct answer
Something like:
struct _Trivia
{
string strQuestion;
vector<string> vecChoices;
string strAnswer;
};
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello all,
I have created one outlook addin.
In which ihave made one toolbar and button. Now when i click on button i want to show one dialog box.
I am able to show dialog box but the style of dialog box is of type windows 98 style even when i create it in design view, it is of the type Xp style.
Any body tell me what should i do so that the dialog box apear in Xp style.
Its realy eargent. I am newbe to outlook addin
Thanks i advance
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
dear all
sorry to ask so basic question, i am newcomer, when i compiled, if some errors occurred, always show C2668 or C2783, what is C2669 and so forth? the following question is what i mentioned in title. thanks a lot.
gentleguy
|
|
|
|
|
Which sqrt are you referring to?
The CRT function sqrt() has four overloads...you need to provide enough
info about the types of the return value and the passed argument so
the compiler knows which one to use.
int n = sqrt(3);
double d = sqrt(2.0);
int n = (int)sqrt((double)3);
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello everyone,
Two questions,
1.
The following compiler error from the following code segment, is because delete statement from destructor of auto_ptr requires the declaration of destructor of wrapped object?
1>main.cpp
1>d:\visual studio 2008\projects\test_autoptr2\test_autoptr2\main.cpp(10) : error C2512: 'Foo' : no appropriate default constructor available
#include <memory>
#include <iostream>
using namespace std;
class Foo;
void func()
{
auto_ptr<Foo> pf (new Foo());
cout << "I am here. " << endl;
return;
}
int main()
{
func();
return 0;
}
class Foo {
};
2.
If yes, how to define a destructor outside of the body of class declaration? I defined in this way, but compile can not pass.
Foo::~Foo()
{
}
thanks in advance,
George
|
|
|
|
|
George_George wrote: 1.
The following compiler error from the following code segment, is because delete statement from destructor of auto_ptr requires the declaration of destructor of wrapped object?
the compiler error statement shows error on costructor and why you suspect the destructor.
auto_ptr<Foo> pf (new Foo()); and the eror is not related to autoptr, it is pointing to the statement with in it, "new Foo()" this requires the declaration of Foo to be visible.
And why do you given a forward declaration of class Foo.
|
|
|
|
|
Thanks Rajkumar,
I have found this issue, we should declare (not necessary to implement) constructor and destructor before using new to create the object, right?
regards,
George
|
|
|
|
|
George_George wrote: we should declare (not necessary to implement) constructor and destructor before using new to create the object, right?
yes, that holds for not only constructor and destructor but any member.
|
|
|
|
|
Thanks Rajkumar,
Any other member you mean like default assignment operator?
Rajkumar R wrote: but any member
regards,
George
|
|
|
|
|
I mean if you are accessing any member, member data, member function you need declaration, forward declaration is not sufficient.
|
|
|
|
|
No Rajkumar,
I do not agree with you. I think forward declaration is enough,
here is my code to prove, any comments?
#include <memory>
#include <iostream>
using namespace std;
class Foo {
public:
Foo();
~Foo();
};
void func()
{
auto_ptr<Foo> pf (new Foo());
cout << "I am here. " << endl;
return;
}
int main()
{
func();
return 0;
}
Foo::Foo()
{
}
Foo::~Foo()
{
}
regards,
George
|
|
|
|
|
I don't think this is the proof of concept code. AFAIK, this code has the full declaration of class Foo before it is referenced in func(), compared to the previous where you did class forward declaration "class Foo; only"
Try the following as in your previous post.
using namespace std;
class Foo;
void func()
{
auto_ptr<Foo> pf (new Foo());
cout << "I am here. " << endl;
return;
}
int main()
{
func();
return 0;
}
class Foo
{
public:
Foo();
~Foo();
};
Foo::Foo()
{}
Foo::~Foo()
{}
i did a quick search now this link may gives some idea on Class Forward Declaration When Full Declarations Are Not Required[^]
modified on Friday, March 21, 2008 8:50 AM
|
|
|
|
|
Cool, Rajkumar!
Question answered.
regards,
George
|
|
|
|
|
hello all:
i have a prolem to ask
i want to creat a dll
in this dll i hava a class i want to export the function of the class
whether i can invoke the export function of the dll using c lanuage programmer?
a beginner
|
|
|
|
|
See here.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Broken link alert
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
thanks all
i got the method
I use the class in a global function
then i deifne the global function as export function
a beginner
|
|
|
|
|
alphaxz wrote: I use the class in a global function
then i deifne the global function as export function
If that's what you want. That's not the same as exporting a
function of a class. That's like using C++ without classes - C.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
WOW, C++ classes encapsulation with C global functions. Is that the C-nemesis pattern?
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
|
|
|
|
|
We're not supposed to mention the C-nemesis pattern, are we?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
It depends on the mood of the day.
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
|
|
|
|
|
Are you sure? It should go to James' post below.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|