69 Posted Topics
Re: [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 … | |
Re: 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. | |
Re: [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; … | |
Re: 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 … | |
Re: 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] … | |
Re: [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 … | |
Re: [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 … | |
Re: [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 … | |
Re: 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 … | |
Re: 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. | |
Re: [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 … | |
Re: [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> … | |
Re: > 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 … | |
Re: [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 … | |
Re: [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 … | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: 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) … |
The End.