69 Posted Topics

Member Avatar for alexRivera

[QUOTE=alexRivera;1153156]i'm currently taking c++ courses in my college and have been noticing that i'm having trouble grasping the fundamentals of programming or even understanding the concepts that are being taught. the courses are taught with no textbook whatsoever so going back for references leaves me with my lecture notes and …

Member Avatar for alexRivera
0
100
Member Avatar for clutchkiller

No. there is no diference whatsoever. i think that class was used originally when templates were added to C++ to avoid adding a new keyword, however eventually a new keyword was added anyway.

Member Avatar for mrnutty
0
125
Member Avatar for tom384

[QUOTE=tom384;1151651]Hi guys, I'm having trouble using a pointer to a vector<float>, it doesn't seems to be responding as I'm expecting it to. Probably a silly mistake on my behalf, but would anyone kindly point it out please. [code] vector<float>* t_matrix; ... cout << "get_t_matrices 0: " << Character::anim.get_animations()[j].get_t_matrices()[0].size() << endl; …

Member Avatar for mattjbond
0
197
Member Avatar for jakesee

The syntax for your call is not quite right. See below... [CODE]#include <iostream> #define CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember)) class Apple { public: typedef int (Apple::*juicer_ptr)(); Apple(int i) { if(i == 1) { juicer_ = &Apple::one; } else if(i == 2) { juicer_ = &Apple::two; } } juicer_ptr juicer_; int one() { return …

Member Avatar for mattjbond
0
149
Member Avatar for dilas

Why are you specializing the templates on type bool? I'm not 100% sure what your intention is but I think i'd start by trying something like this... [CODE]template<typename b> void foo(); template<typename b> struct C { template<typename b> class B { friend void foo<b>(void); }; }; template<typename b> void foo(){};[/CODE] …

Member Avatar for dilas
1
165
Member Avatar for jBat

[QUOTE=jBat;1150339]Hi, I'm trying to convert a void pointer to a struct pointer.. that's seems very easy but my compiler give me error. Thanks. /home/subi/Personal/Projects/LinkedListUserInfo/main.cpp||In function ‘error_t parse_opt(int, char*, argp_state*)’:| /home/subi/Personal/Projects/LinkedListUserInfo/main.cpp|50|error: expected primary-expression before ‘)’ token| /home/subi/Personal/Projects/LinkedListUserInfo/main.cpp|50|error: expected ‘;’ before ‘null_pointer’| /home/subi/Personal/Projects/LinkedListUserInfo/main.cpp|48|warning: unused variable ‘null_pointer’| ||=== Build finished: 2 errors, 1 …

Member Avatar for jBat
0
135
Member Avatar for Kikazaru

[QUOTE=Ancient Dragon;1149277]Whether or not there is computational time will be compiler dependent. Assuming you have a good optimizing compiler and do NOT compile the program for debug, the compiler will may or may not toss out any storage for constants and keep the value in registers. That, however, is pretty …

Member Avatar for vijayan121
0
3K
Member Avatar for merse

[QUOTE=merse;1149565][CODE] #include <limits> using namespace std; const double double_nan = numeric_limits<double>::quiet_NaN(); double x = double_nan; if (x == double_nan) cout << "OK" << endl; [/CODE] I dont get OK! Why?[/QUOTE] Because a NAN wont compare to anything, even itself. You'd need to check the IEEE standard on floating point numbers …

Member Avatar for dusktreader
0
106
Member Avatar for Mridula J

When the compiler inline-expands a function call, the function's code gets inserted into the caller's code stream (conceptually similar to what happens with a #define macro). This can, depending on a zillion other things, improve performance, because the optimizer can procedurally integrate the called code — optimize the called code …

Member Avatar for mattjbond
0
132
Member Avatar for halluc1nati0n

Looks like you may have blown your stack. Your compiler probably sets an initial stack size which your array size exceeds. You should check you compilers linker settings to look for stack size settings and experiment with these until you find a size which works.

Member Avatar for halluc1nati0n
0
209
Member Avatar for karolik

[QUOTE=karolik;1148109]So I made a template...I tried declaring a string linkedlist like so... [CODE]LinkedList<string> str; [/CODE] Then i called the function insertLast to insert a string called hello..like so... [CODE]str.insertLast("hello")[/CODE] Then it gives me null pointer error...I cannot see how there can be a null pointer...help would be appreciated..Here is the …

Member Avatar for mattbond
0
182
Member Avatar for josolanes

[QUOTE=josolanes;1146913]Memo.h: [CODE=cpp] #ifndef _MEMO_H #define _MEMO_H #include <stdlib.h> #include <string> #include <typeinfo> #include <iostream> #include "Date.h" #include <map> #include <vector> using namespace std; class Memo { public: map<Date, vector<string> > Appointment; //void delMemo(int x); void addMemo(Date myDate,string x); }; #endif /* _MEMO_H * [/CODE] Memo.cc [CODE=cpp] #include <stdlib.h> #include <string> …

Member Avatar for josolanes
2
224
Member Avatar for Cristofor

> Hi, I am using Visual Studio 2008 Express Edition, and I wrote my code as follow: #include <iostream> #include <string> #include <sstream> using namespace std; int main() { string *p; int n; cout << "Please input the number of students"<<endl; cin>>n; p = new string [n]; cout <<"Please input …

Member Avatar for Cristofor
0
106
Member Avatar for webdragon89

[QUOTE=webdragon89;1146876]I have: [CODE]void hughint::operator *=(hughint y) { int i,t1,t2,prod,remainder; int carry=0; for(i=num.length()-1;i>=0;i--) { t1=(int)get(i)-(int)('0'); cout<<"t1: "<<t1<<endl; t2=(int)y.get(i)-(int)('0'); cout<<"t2: "<<t2<<endl; if(carry>0) { prod=(t1*t2)+carry; remainder%=10; carry=remainder/10; } } }[/CODE] I'm using 123*100 and the answer I keep getting is 123. Help please.[/QUOTE] You need to show more of your code, eg. your …

Member Avatar for mattjbond
0
111
Member Avatar for axed

[QUOTE=axed;1145753]Wonderfully explained. Thanks a lot. So this memory allocation for static variables is neither on heap nor on stack right, its all inside the executable.[/QUOTE] this is an excerpt from The C++ programming language which explains the three types of memory usage available in C++. This should provide you with …

Member Avatar for axed
0
160
Member Avatar for maharjun

You have further issues with this code. Your main problem is centered around poor design, as previously stated yoiu have not correctly defined your assignment operator=, but in addition to this you should also define a copy constructor of the form - [CODE] String( const String& str ) { string …

Member Avatar for mattjbond
0
181
Member Avatar for karolik

From the code yoiu have posted I cannot see your problem. LinkedQueue is not const in this example. Please post the exact code which is giving you your problem.

Member Avatar for mattjbond
0
117
Member Avatar for mmasny

That would depend on the inteded usage of your class. You do not say, or show with an example code snippet, how you are using the class. Is the class intended to manage a resource? Is the dynamically allocated object created by this class or does it live elsewhere? You …

Member Avatar for mmasny
0
155
Member Avatar for Aser10

In C++ there is only one valid defintion of main and it is int main() { } or int main( int argc, char** argv ) {} A main should return an int. If the return is ommitted as it is here then the compiler will implicitly return 0. int main(void) …

Member Avatar for Aser10
0
80

The End.