Posts
 
Reputation
Joined
Last Seen
Ranked #2K
Strength to Increase Rep
+0
Strength to Decrease Rep
-0
100% Quality Score
Upvotes Received
4
Posts with Upvotes
3
Upvoting Members
4
Downvotes Received
0
Posts with Downvotes
0
Downvoting Members
0
2 Commented Posts
0 Endorsements
Ranked #3K
~3K People Reached
Favorite Forums
Favorite Tags

16 Posted Topics

Member Avatar for aravind rao

Why would you want to simulate a stack for a vector if there is already an implemented stack?! [CODE]#include <stack> #include <iostream> int main() { std::stack<int> st; st.push(1); st.push(3); std::cout << st.top() << std::endl; // outputs 3; st.pop(); std::cout << st.top() << std::endl; //outputs1 }[/CODE]

Member Avatar for aravind rao
0
179
Member Avatar for RFID46616c73

Die::Die() //Initializes Face data member { Face = 1,2,3,4,5,6; } I am not sure what you wanted to achieve by this, but this assigns 6 to Face. The operator comma works like this - it evaluates all of its arguments from left to right then returns the rightmost argument, in …

Member Avatar for RFID46616c73
2
1K
Member Avatar for majeissh

Fbody's solution is a bit bad because it changes the semantics of the built-in operator-. Consider it. [CODE]struct example { int anInt; }; //Overload the Unary minus for the "example" struct: void operator- (example &o1) { o1.anInt = -o1.anInt; } #include <iostream> void Print(example e) { std::cout << e.anInt; } …

Member Avatar for Fbody
0
225
Member Avatar for MarounMaroun

You have never allocated memory for AgentP member. This should fix the problem [CODE]Agent::Agent(std::string name) :AgentP(new AgentStruct()) { AgentP->nextAgent=NULL; AgentP->agentName=name; AgentP->pID=setPID(); AgentP->mID=AgentP->pID; } [/CODE]

Member Avatar for mike_2000_17
0
181
Member Avatar for Dark Byte

::name is explicitly specifying that name is in global namespace example 1: [CODE]int i = 3; int main() { int i = 4; if(true) { int i = 5; int j = ::i; //j is set to 3 } } [/CODE] example 2: [CODE]int main() { int i = 4; …

Member Avatar for LordNemrod
0
117
Member Avatar for Stefano Mtangoo

I know I'm a bit offtop here, but I would like to say that not only the default access of members is the difference between a class and a struct,but also the access of derivation is public for structs by default and private for classes. Also the word class can …

Member Avatar for LordNemrod
0
102
Member Avatar for vbx_wx

[CODE]#include <algorithm> void reverse(char* str) { std::reverse(str, str+strlen(str)); }[/CODE]

Member Avatar for LordNemrod
0
295
Member Avatar for syd919

You mean 1 decimal place after the point? Like 13.4 or 2333.4. I'll go with yes. If you want to obtain the value with 1 decimal place after the point, then you should do this double x = some value; double y = x = int(x*10)/10.0; this will however not …

Member Avatar for syd919
0
166
Member Avatar for vbx_wx

pointer to array of character strings... If by character string you mean const char*, and if you MEAN you want to declare a pointer to array of pointers to const char(which I doubt), then it will be like this [CODE]typedef const char * str_type; typedef str_type arr_type[100]; typedef arr_type* my_desired_type; …

Member Avatar for LordNemrod
0
133
Member Avatar for hurbano

first of all, instead of [CODE] while(1){}[/CODE] write [CODE] cin.get(); [/CODE] :) Second, can't see a destructor that deletes all the memory you've new'd. Third, getStudent can be much shorter, like this [CODE] void getStudent (string student) { node* current = start; while(current!=NULL) { if(current->name == student) { cout << …

Member Avatar for hurbano
0
100
Member Avatar for delle

in the end of main, write cin.get() which will wait for you to press enter so it won't close

Member Avatar for Duki
0
210
Member Avatar for onako

float a; cin >> a; a = a*a; well, this is the fastest way I am aware of, perhaps you could make it a tiiiiiiiiiiny bit faster with a *= a; but probably most compilers will optimise this anyway. Bit shifting is about integers, and you can't use it (I …

Member Avatar for NathanOliver
0
80
Member Avatar for onako

I believe the specialization alternative (although technically speaking function templates cannot be specialized, this is rather an overloading) is indubitably superior to the Runtime Type Identification.

Member Avatar for LordNemrod
0
113
Member Avatar for XodoX

I am not sure if I understand your question correctly. Do you mean you want to read a file into an array of words? or lines? Anyway, why use arrays instead of vector? I would do it like this [code] #include <fstream> #include <string> #include <vector> int main() { std::vector<std::string> …

Member Avatar for LordNemrod
0
109
Member Avatar for rtdunlap

[QUOTE=daviddoria;1325204]You need to put single quotes around the letters You should also [icode]return 0;[/icode] at the end of main(). You should also have an [icode]else[/icode] statement to help catch things like this :) Hope that helps, David[/QUOTE] You absolutely should not. The current C++ standard requires that the return type …

Member Avatar for LordNemrod
0
123
Member Avatar for ganesh_IT

assert(expr); if expr evaluates to true, then OK else if in debug mode - calls abort else - does nothing but this is probably bad one can use BOOST_VERIFY which is basically like assert, but works in release mode too

Member Avatar for LordNemrod
0
74

The End.