1,426 Posted Topics
Re: the `>>` and `<<` operators are overloaded for `char*`. Since you have an operator `char*` defined for you class it is implicitly convertable into a `char*`. Since it is implicitly convertable you can use it with the default stream operators. For your second question `strcmp()` reutrns an integer depending on … | |
Re: `string` is defined in <string> and the defenition of `string` is `typedef basic_string<char> string;`. `string` is just a typdef and there is no actual string class in the standard. Whenever you want to use a `std::string` then you need to `#include <string>` | |
Re: Here is a good reference site: http://en.cppreference.com/w/cpp/language/template_parameters | |
Re: The since you are using operator bool it will only be false when `badbit` and or `failbit` is set. The first time you close the file and evaluate operator bool none of those are set so the operator returns true. Calling `close()` on the stream a second time will fail … | |
Re: @basit_3 you need to convert the `String^` to a `std::string` if you need want to use `std::ofstream` you con use this to convert the string(source: [MSDN](https://msdn.microsoft.com/en-us/library/1b4az623.aspx)): // convert_system_string.cpp // compile with: /clr #include <string> #include <iostream> using namespace std; using namespace System; void MarshalString ( String ^ s, string& os … | |
Re: Now that we have C++11 there are two options when you want an array object and don't want to use a native array. If you want an array of a fixed size you should use a [`std::array`](http://en.cppreference.com/w/cpp/container/array). This has the benefit over native arrays where if you pass it to … | |
Re: You should never include a .cpp file in another file. .cpp files should include .h/.hpp files and then all of those .h/.hpp and the .cpp file get compiled together to make an object file. This should happen for each .cpp file you have in your project. Once that happens then … | |
Re: The `push_back()` function of standard container appends to the end of the container the value passed to it. If the `size()` of the container equals the `capacity()` of the container then the container will grow to accommodate the new element. | |
Re: What no one helped you the [first time](https://www.daniweb.com/software-development/cpp/threads/495354/digital-clock) so you are trying again? It's been 5 days and all you have come up with is "give me the code". | |
Re: Don't use `goto`. In this case to get out of your nested loops just use `return a*b*c;` where you have `goto End_of_Loop;`. There is no point exiting out of the loops to get to the return statement when return will kill the function for you. | |
Re: @rubberman According to the standard 3.6.1.5 main has an implicit `return 0;` if one is not provided >A return statement in main has the effect of leaving the main function (destroying any objects with automatic storage duration) and calling std::exit with the return value as the argument. If control reaches … | |
Re: Can you post the code that is giving you the warning? If you never use `number2` then you should be able to just get rid of it. | |
Re: You are pushing back the number on line 19 in your second code block. Get rid of that and you should be fine. cout<<"Enter a nonnegative integer:"; cin >> num; stack1.push(num); while(num>0) //... Becomes cout<<"Enter a nonnegative integer:"; cin >> num; while(num>0) //... | |
Re: You don't have any structs. Are you trying to sort parallel arrays? | |
Re: So what part is giving you a problem? | |
Re: Is the `podofo.lib` file located in the directories you have listed? | |
Re: Didnt like your [downvote](http://stackoverflow.com/questions/29375458/c-minimum-distance-between-cities-and-minimum-travel-time-error)? | |
Has anyone noticed that there seams to be a large number of new users that are just copy and pasting their homework requirements into their post and that's it? Do we have anything like SO that analyzes post to see if they might not meet the sites standards? Just from … | |
Re: I just want to point out that if part of the requirement is to not use any dynamic memory allocation you shouldn't be able to use a vector. A vector is just a wrapper for a dynamic array. I am being a little nit picky about that but your professor … | |
Re: You need to add them to the solution. | |
Re: You are going to have to loop through your data and find the min and max frequency. Then you have to loop through your array and print out all of the numbers that have the same max frequency. Then you have to loop through your array and print out all … | |
Re: Repeating the same bad question isn't going to help you. Take a look at the [rules](https://www.daniweb.com/community/rules) and also see [how to ask a good question](https://www.daniweb.com/software-development/cpp/threads/78223/read-this-before-posting-a-question) ![]() | |
Re: To loop a whole program this is what I use: char continue; do { // program code goes here std::cout << <<"Press 'Y' to repeat and 'N' tp exit\n"; std::cin >> continue; } while (::tolower(continue) != 'n'); This will continue the loop as long as an `N` or `n` is … | |
Re: Did you try to [google](http://lmgtfy.com/?q=passing+arrays+to+functions+c%2B%2B) that? | |
Re: Please detail what the problem is, what you have tried to solve it and any errors you are getting with the code you have. | |
| |
Re: When doing operations like this you should look at using the [copy and swap idiom](http://stackoverflow.com/a/3279550/4342498). | |
Re: Does line 7:`int func(int);` look the same as line 22:`int func(int base, int power)`? | |
Re: This is why [proper indention](http://en.wikipedia.org/wiki/Indent_style) is so important. | |
Re: Congratulations. C++ is a very complex and powerfull language. If you are looking for reference on how to learn C++ I would visit [here](https://www.daniweb.com/software-development/cpp/threads/70096/c-books) | |
Re: Why would you have a virtual constructor? The reason you use `virtual` is to create a virtual table so that when a function is called from a pointer to a base it will call the function of the derived object that was stored in that pointer. Since you have to … | |
Re: `*(C + B) = A;` = `C[B] = A;` `*(G + F + 1) = E;` = `G[f+1] = E;` | |
Re: With the number of people posting just their homework maybe the instructors have noticed that and made the assignments easier to give us a break ;) | |
Re: You should not be getting any input from the user. You need to figure out how many appointments the sales person can do per day. Once you know that then you know how many visits he can do in 2 weeks. Once you have that then you can multiply the … | |
Re: I would think and decent compiler would make `even % 2` and `even & 1` the same operation. My rule of thumb is write clear and legible code. This will help with maintainability and will generally allow the optimizer to take care of most optimizations that can been done. [mike_2000_17](https://www.daniweb.com/profiles/787121/mikael-persson) … | |
Re: This is not a code writing service. If you have code and it is giving you a problem then post the code and what the problem is. No one here is going to do your work for you. | |
Re: I'm pretty sure this was given to you to answer. | |
Re: This is not a code writing service. If you have code and it is giving you a problem then post the code and what the problem is. No one here is going to do your work for you. | |
Re: @rubberman Microsoft does offer an express version of MS SQL Server that is free. I am looking at that right now for some time and attendance software that needs a DB for the backend. You can check it out [here](http://www.microsoft.com/en-us/server-cloud/products/sql-server-editions/sql-server-express.aspx). | |
Re: Now if he offered to pay for this that would be a different story. I don't know about the rest of you but I think if the OP offered $1000 USD per hour at a minimum of 8 hours we would be more inclined to help. | |
Re: Just another person hoping that the internet is the answer to all of lives problems. | |
Re: If our output should be: Popping...a Popping...b Popping...c Popping...d Popping...e Popping...f Then you need to be storing a,b,c,d,e and f in your stack. right now you are storing 1,2,3,4 and 5 with `char a='1',b='2',c='3',d='4',e='5',f='6';`. You can change it to `char a='a',b='b',c='c',d='d',e='e',f='f';` to get the desired output. The stack is only … | |
Re: What a great post Mikael. I never though about sorting derived objects in the container so that the same function keeps getting called. I would suppose this would also help with vtable lookups? I do have a question regarding precomputation of values. Lets say that I have a `std::vector<std::vector<int>>` where … | |
Re: @ddanbe: A char is an integer type so it can be implicitly converted to an int. Since `sizeof(char) <= sizeof(int)` there is no loss of precision. C++ uses 5.2.4.2.1 from the C standard for its integer sizes. http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf Page 22. | |
Re: You have to initialize the static member outside of the class. /Foo.h class Foo { static int bar; //... }; // Foo.cpp int Foo::bar = 1; If the initialization is in the header file then each file that includes the header file will have a definition of the static member. … | |
Re: The only thing I can think of is that maybe you are to use a stream iterator and loop through it outputting what you need each iteration. This seams like a very nonsense question. | |
Re: 1) Open program to write code 2) Write code 3) Compile code 4) If you have errors fix them and go to step 3 else continue 5) Run code and make sure you get what you want else go to step 2 | |
Re: You need to have a void function that displays the area of the circles in the array. It should be like void DisplayArea(Circle[NUM_CIRCLES] circles) { for (int index = 0; index < NUM_CIRCLES; index++) { cout << "Circle " << (index+1) << setw(8) << circle[index].findArea() << endl; } } Then … |
The End.