- Strength to Increase Rep
- +6
- Strength to Decrease Rep
- -1
- Upvotes Received
- 15
- Posts with Upvotes
- 13
- Upvoting Members
- 13
- Downvotes Received
- 4
- Posts with Downvotes
- 4
- Downvoting Members
- 4
107 Posted Topics
Re: Abstract Data Types is a way to generalize/model software so that the same interface used with different implementations and types. Standard Template Library is a good example of Abstract Data Types. For example the interface for stack is independent of the implementation. Under the hood stack may be implemented by … | |
Re: [CODE] std::stringstream out; for(size_t i=0; i < size; i++) { int x = digit[i]; x = x >> i; // do something to digit out << x; } [/CODE] | |
Re: Objects and thread work together well. Try to model your problem in terms of classes. For example Shuttle can be designed as an active class | |
| |
Re: Comparing floating point numbers using == or != is not safe. The difference between the two numbers must be compared to some tolerance, usually the system epsilon. (see sample code below). [code] bool isEqual( float v1, float v2 ) { if( std::abs(v1-v2) < std::numeric_limits<float>::epsilon() ) { return true; } return … | |
Re: I would think a terminal condiion is needed, some way to end it all... | |
Re: Stuff is always hard at first... Take a stab at it, write some code to get started.. | |
Re: [CODE] bool isSame(double a, double b) { return std::fabs(a - b) < std::numeric_limits<double>::epsilon(); } [/CODE] | |
Re: 34 is the right answer two minus becomes plus [url]http://wiki.answers.com/Q/Do_a_minus_and_a_minus_make_a_plus[/url] | |
Re: max is most likely 2, because you must be passing 2 Code presented is incomplete, so its hard to figure out why. | |
Re: What is your intent of distance=0? You already initialized the contents of array. Seem like you can just remove that statement. [CODE] void Graph::initialize() { for(int i=0;i<numOfVertices;i++) { mark[i] = false; predecessor[i] = -1; distance[i] = INFINITY; } [B]distance = 0; //here is the problem...[/B] } [/CODE] | |
Re: If you are permitted to do so, you can perhaps load your text file into a std::set and use that as your dictionary. ![]() | |
![]() | Re: Perhaps a custom sort on the vector might solve your problem. See attached link for ideas [url]http://stackoverflow.com/questions/1380463/sorting-a-vector-of-custom-objects[/url] |
Re: Do do not need to or want to put your executable in VC folder. set the path to location of dumpbin (there should be a batch file that sets this path) and run dumpbin on your executable where it is currently locationed | |
Re: Perhaps an expression evaluator such as below... [url]http://www.arstdesign.com/articles/expression_evaluation.html[/url] | |
Re: This is an observer pattern problem. [url]http://sourcemaking.com/design_patterns/observer[/url] Therefore you need an observer, which keeps a list of all dependents. When an update is received observer loops through and updates all dependents. Using one thread per client is not going to scale very well if you intent to have many chatters. … | |
Re: [url]http://linux.about.com/library/cmd/blcmdl1_md5sum.htm[/url] [url]http://www.gnupg.org/[/url] | |
Re: C++ does name mangling to ensure method/function names are unique, C does not. So when calling C function from C++ you need to let C++ know it’s a C function. This can be done using the extern "C", read below for examples [CODE] extern "C" { #include "header.h" } [/CODE] … | |
Re: try using gettimeofday, will give you usec rather than seconds sample code [url]http://www.daniweb.com/software-development/cpp/threads/361138[/url] | |
| |
Re: If you have a pointer to array, you can use it as an array... [CODE] int main() { int a[]={1,2,3}; int* p=a; int val=p[0]; } [/CODE] | |
Re: try it in c first, just for fun. Here is something to get you started, complete the function, use algorithm described by Narue.. [CODE] char *reverse( char *input) { } [/CODE] | |
Re: [CODE] struct timeval { unsigned long tv_sec; /* seconds since Jan. 1, 1970 */ long tv_usec; /* and microseconds */ }; [/CODE] | |
Re: perhaps something like this [url]http://stackoverflow.com/questions/5265607/how-to-send-double-click-on-keyboard-focused-object-from-c[/url] | |
Re: Seems, fine, ensure you have the correct headers. [CODE] #include <vector> #include <string> int main() { std::vector<std::string> TexName; TexName.push_back("mega.png"); return 0; } [/CODE] | |
Re: What input sequence causes core dump? seems to work on my machine... | |
Re: 1. Allocation means to create space for your application use 2. Initialize means to assign specific values to that space Using malloc creates space, but contents of space undefined | |
Re: try [url]http://www.kernel.org/doc/man-pages/online/pages/man3/usleep.3.html[/url] | |
Hello Community, I am trying to figure a simple way approximate cost of context switching for a given OS/hardware combination under different loads. For example on my 2 GHz dual core MAC OSX, running single instance clocks at 0.5 usec where as three instance at 1.3 usec. Below is sample, … | |
Re: 1. use typedefs to simlify your code 2. use strings rather than char* for key in containers. 3. if you must use char *, custom comparison perdicate must be provided Below is simple sample [CODE] #include <iostream> #include <string> #include <map> int main() { typedef std::map<std::string,std::string> TMap; TMap m; m["k2"] … | |
Re: Quote: "However, I am developing a collection of classes and I need them all to share a common variable (a time step) whose value will be defined by the user." Since the values is defined by user, its similar to a configuration value, therefore const is probably not what you … | |
Re: If you reorganized, restructure and format you code so it easy to read and understand, it will simplify finding both logic and syntax problems. As your programs get larger, good code organization will save you lots of time and effort. If I read correctly, line 31 is the end of … | |
Re: I almost always disable the precompiled header, less problems in the long run. | |
Re: Did you try to use a debugger to figure out what/where the problem is? | |
Re: what is the question???? what do you need help with? | |
Re: It appears linker is not seeing the definitions for Client. Is Client.cpp compiled and linked with application? | |
Re: [QUOTE]It returns the number of seconds since 1970, as you previously posted. It doesn't matter whether the parameter is NULL or not, it will always return the same value.[/QUOTE] Although the c standard may be fuzzy on the topic, the posix standard appears to be more specific. Although exception are … | |
Re: Perhaps try something like below... [CODE] #include <iostream> #include <string> using namespace std; int main() { int start; int end; cout << " Time Clock Program" << endl; cout << "Enter Start time (hh:mm A/P): "; cin >> start; cout << std::endl << "Enter Stop time (hh:mm A/P): "; cin … | |
Re: [CODE] struct Point; // forward reference struct MyClass1{Point &p;}; // reference to Point (ok) struct MyClass2{Point *p;}; // pointer to Point (ok) strcut MyClass3{Point p;}; // Pointer Object (compile error) [/CODE] Forward reference are used to inform the compiler a name is valid and defined somewhere else. However if the … | |
Re: It seems like the linker thinks there is no int main() function..., what does you main look like? | |
Re: [CODE] /// /// below is pseudocode/pattern on a possible way to /// start a pool of thread and end them gracefully /// need thread and conditon variable implementation /// #include <iostream> #include <vector> /// /// replace with your thread class /// class Thread { public: virtual ~Thread(){;} protected: virtual void … | |
Re: Might be cleaner if you design you problem in terms of objects (use classes) | |
Re: Depends on what you want/like to do and which platforms you are interested in... Having said that, c++ is a good language to have in your skill set. | |
Re: An alternative is to have the push return true/false... [CODE] template<int MAX_SIZE> class Stack { public: Stack() :_count(0) { } bool push(int val) { if( _count < MAX_SIZE ) { _array[_count++] = val; return true; } return false; } private: int _count; int _array[MAX_SIZE]; }; [/CODE] | |
Re: I am able to compile and link using g++, with changes below. 1. in FriendClass.h remove MyClass.h include and provide forward declaration for MyClass 2. In MyClass.h include FriendClass.h | |
Re: Some windows synchronization objects, its usually best to use c++ wrappers with these (google for more information) [url]http://msdn.microsoft.com/en-us/library/ms685129(v=vs.85).aspx[/url] [url]http://msdn.microsoft.com/en-us/library/ms682411(v=vs.85).aspx[/url] [url]http://msdn.microsoft.com/en-us/library/ms682530(v=vs.85).aspx[/url] [url]http://msdn.microsoft.com/en-us/library/ms682396(v=vs.85).aspx[/url] |
The End.