2,712 Posted Topics
Re: Is that function a virtual function, can you change its sigs? Why not return a `std::pair<bool,Handle>` ? | |
Re: Your code seems fine, it might be how you setup the environment. How'd you set up your environment? I haven't used netbeans in years. But typically in any ide, there is an option to create a C++ project. Did you try to run a simple hello-world program and see if … | |
Re: bool operator==(const Birthday &x, const Birthday &y) { if ((x->getMonth() == y->getMonth()) && (x->getDay() == y->getDay()))//i am getting errors here return true; else return false; } Bad syntax above, try this: bool operator==(const Birthday &x, const Birthday &y) { return (x.getMonth() == y.getMonth()) && (x.getDay() == y.getDay()); } | |
Re: ok cool, don't forget to delete what you `new`-ed. What is your question? | |
Gravatar is getting really popular, may sites like stackoverflow or github have incorporated the avatars. It would be nice to have a consistent avatar throughout all forums and sites. | |
Re: I hope you know that `std::string` has a `find` method in which you can use to find another string. So for your Contains function, you can simply so something like so: bool contains(const std::string& target, const std::string& src, bool ignoreCasing = false){ const std::string& adjustedSrc = ignoreCasing ? toLower( src … | |
Re: In C++ `1/2 = 0` because of inteeger division. Thus you want something like so: float divide(float x, float y){ return x/y;} int main(){ float x = 0, y = 1; cin >> x >> y; cout << divide(x,y) << endl; } | |
Re: You want to get the input and set the member variables: #include<iostream> #include<string> using namespace std; class student { public: void input(); float GPA() const; void Display() const; private: string name; int id; int grade1; int grade2; int grade3; }; int main() { student kyle(name, id, grade1,grade2,grade3); kyle.Display(); return 0; … | |
## I know we haven't been doing much of these C++ Community problems so I though I'd write one up to get it started once again.## **Problem Statement:** For some integer `v,w,x,y,z` find all solution to the following equation 1 1 1 1 1 - + - + - + … | |
Re: if(Clock.GetTime() >= FPS){ Screen->StartFrame(); Player.Draw(); Screen->ShowFrame(); Clock.Start(); } Why do you do Clock.start() here again? A better way to handle it is like so: if(Clock.GetTime() >= FPS){ Clock::TimeDiff diffTime = Clock.GetTime() - FPS; updatePhysics(diffTime); updateEntities(diffTime); } Check out a full tutoial [here](http://gafferongames.com/game-physics/fix-your-timestep/) | |
Re: Hmm...seems like its a little more complicated than it needs to be. Some of your algorithms can be simplified using the algorithms in the string library, for example: std::string GetExtension(const std::string& filename){ _validate(); //your exception validation auto endExtensionPosition = filename.find_last_of('.'); auto endPathSeperatorPosition = filename.find_last_of("/\\"); if(endPathSeperatorPosition > endExtensionPosition || endExtensionPosition != … | |
Re: If you don't know the size of the parameter 'a' in your example, then it is not possible to correctly write the needed logic with the given information. Sure we can assume things such as the char array is null terminated which is a natural assumtion in this case, but … | |
Re: There are so so many tutorials online about this. I'm not sure what you are confused by. As a quick glimpse, consider the following code: //base class struct Base{ int x; virtual ~Base(){}; }; //inherit properties and method from Base class struct Derived: Base{ int y; }; After the derived … | |
Re: Seems like you need to first understand how to convert binary to decimal before actually programming it. Take for example the binary number `1010` which is 10 in decimal. How can we get to it mathmatically? Pretty easy actually, what you can do is sum up pow(2,nextOnePosition). For example, 1010 … | |
Re: I think you want something like so: #include <iostream> #include <fstream> int main(){ using namespace std; ofstream fileOutput("data.dat",ios::app); //open for appending cout << "What is your favorite number: "; //print to standard output the question int favNum; //create variable to store number cin >> favNum; //read response from user from … | |
Re: Few reasons why I prefer google than others - It is popular, usually crowd knows best in the realm of technology - It is fast - It returns better search results than other few search engines that I've tried - And is continually building | |
Re: Check it [out](http://codepad.org/ydLbWKA3). For some numbers like 101,`reverse(110)` returns 11. So your reverse function isn't completely correct. | |
Re: From the given language, try to write some sample events generated by the given language. Then that might help you formulate a grammar for the general case. | |
What's up ladies and gents. I've been lacking motivation to program lately. I've been doing a little programming here and there, but I work so I mostly program for my job. However, whenever I have free time, I use to program a lot, but that motivation and has been gone … | |
| |
Re: Try `cout << timeFunction( standardDeviation<delctype(v)>, v);` Why don't you make your timeFunction a template parameter as well? | |
Re: - Check if the board is full, meaning that all cells are occupied and not empty - Then make sure there aren't any winning patterns for 'x' -- use your checkAll('x') - Then make sure there aren't any winning patterns for 'o' -- use your checkAll('o') - If all the … | |
Re: >> int ch, count=0, desc[10]; This is wrong decleration for desc, what you want as suggested is const int MAX_SIZE = 10; desc descriptions[MAX_SIZE] Then on each function you will pass in descriptions and MAX_SIZE like so void del(desc[] descriptions, const int MAX_SIZE, int targetCode){ for(int i = 0; i … | |
Re: @L7Sqr method1 and method2 do two different things. Consider method1(0) and method2(0). In method1 all if gets executed in method2 only the first if gets executed. So I want to make note of the logistic difference between multiple if versus elseif | |
Re: Are you rectangles rotated? Do you expect us to just write one for you? Or do you have a specific question? | |
Re: testClass c ; c.flag = true ; c.flag = false ; c.flag = true ; Can someone explain why this would be a good idea? It seems like a lot of work for little benifit. | |
Re: Rather than trying to explain, I'll [link](http://www.cplusplus.com/doc/tutorial/namespaces/) you to a article that talks about namespace. In general for simple question you should try to be more independent. Take care. | |
Re: If you are returning by value on built in type, don't return it constant. It might confuse the user, but its arguable. See [here](http://www.gotw.ca/gotw/006.htm) | |
I've been just working at this new enhancement for my company for these few months. I feel like my design is actually good in fact one of the best I've written. But don't be mistaken, it probably isn't the best there could be, I just tried to do my best … | |
Re: @Gonbe, I think he wants to know if an arary is a subarray of another array at same position. For example 1 2 4 5 is a subarray of 1 2 3 4 5 6 however 2 1 5 4 not a subarray of 1 2 3 4 5 6 … | |
Re: Yes. here is an example class A{ public: void foo(){ cout << "A" << endl; } }; class B{ public: B(A& a){ a.foo(); } }; int main(){ A a; B b(a); //b will call a.foo in its constructor } | |
Re: Well you can do something like so: Vector3 nextCircularPosition(const Vector3& currentPosition, float angle, float radius){ return Vector3( currentPosition + cos(angle)*radius, currentPosition + sin(angle)*radius } void display(){ Object.position = nextCircularPosition(Object.position,currentAngle,radius); } | |
Re: Somthing like this perhaps template<typename FirstContainer, typename SecondContainer, typename BinaryOp> void iterateTwoContainer(const FirstContainer& firstList, const SecondContainer& secondList, const BinaryOp op2){ for(int i = 0; i < firstList.size(); ++i){ for(int j = 0; j < secondList.size(); ++j){ op2(firstList[i],secondList[j]); } } } void handleItemAndToys(const Item1& item, const Toy& toy){/*...*/} void handleItemAndApples(const Item2& … | |
Re: It is conventional and more readable to use a for loop or a foreach loop, if the language has one. for(int i = 0; i < array.Count; ++i){ Console.Write( array[i] ); } | |
Re: >>leaf = leaf->left; //move leaf 1 time to right That comment conflicts with that is written. >>leaf->key_value = temp->key_value; //assigning temp's key to leaf That's not really needed since leaf is going to be deleted right. Also I'm not sure why you are treating left-child different than right child when … | |
Re: Never used allegro but I assume you can use both at the same time. | |
Re: Also note that you might be able to skip transversal if the number of nodes isn't a power of 2. If it is, then you have to transverse just to make sure it fits the definition. | |
Re: I know the question was who, but lets cover more ground my casting it to what. What makes me happy are the things I love to do and enjoy. Some of which are * Spending time with family * Spending time with my brother, more specifically * Playing basketball * … | |
Re: > Set::Node* cons(int x) The proper syntax is Node* Set:::cons(int x) Similar for the other decleration as well. | |
Re: what language is this? Its hitting default because none of the cases match, try printing out target and see what it shows and try to match it to the case statement. You might just want to check if target contains('Erikpl') to avoid the extra stuff. | |
Re: Accessing arrays doesn't necessiarly have to throw out of bounds exception, at least I don't think that is a standard requirement. Are you in debug mode? Try running it on release mode and see if it throws an exception or crashes? | |
Re: [QUOTE=Ancient Dragon;1679296]despite the infinite loop at the end of main().[/QUOTE] Actually, its finite, the condition is infinite, but this doesn't necessarily mean the loop is infinite. The same code but more OOP style: [code] #include <iostream> #include <string> class Application{ private: std::string title; public: Application(){} Application(const std::string& titleName) : title(titleName){} … | |
Re: First you need to know the [URL="http://hyperphysics.phy-astr.gsu.edu/Hbase/mot.html"]Kinematic Equations[/URL] You can use them to model projectile motion. 1) Have a initial position, initial velocity, final position, final velocity, and acceleration. The acceleration is what is going to make your projectile motion a projectile motion. Here is another refrence , [URL="http://en.wikipedia.org/wiki/Equations_of_motion"]Link[/URL] Particularly, … | |
Re: Yea you seem to be a little confused. First here is how you should declare the class, doing things for simplicity right now. class Coordinate{ //declare a class named Coordinate private: float x; //has a member variable x float y; //has a member variable y float z; //has a member … | |
Re: What do you think it does? Did you test it out? | |
Re: What do you need help with exactly? Start by creating a class which has a char* as a member variable. And get it to allocate when calling the constructor. Then go on from there. | |
Re: You need to also limit your frame rate. See [this](http://gafferongames.com/game-physics/fix-your-timestep/) site for a good reference and code. |
The End.