1,426 Posted Topics

Member Avatar for lewashby

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 …

Member Avatar for NathanOliver
0
201
Member Avatar for nathan.pavlovsky

`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>`

Member Avatar for NathanOliver
0
157
Member Avatar for basit_3

Here is a good reference site: http://en.cppreference.com/w/cpp/language/template_parameters

Member Avatar for Moschops
0
178
Member Avatar for tgreiner

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 …

Member Avatar for Moschops
0
792
Member Avatar for basit_3

@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 …

Member Avatar for NathanOliver
0
180
Member Avatar for kiran_8
Member Avatar for basit_3

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 …

Member Avatar for mridul.ahuja
0
179
Member Avatar for Lutina

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 …

Member Avatar for mike_2000_17
0
276
Member Avatar for basit_3

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.

Member Avatar for Lutina
-1
145
Member Avatar for S-e-c-r-e-t

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".

Member Avatar for NathanOliver
-1
137
Member Avatar for Petcheco

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.

Member Avatar for Petcheco
0
349
Member Avatar for A. Gregory

@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 …

Member Avatar for David W
0
181
Member Avatar for tgreiner

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.

Member Avatar for rubberman
0
4K
Member Avatar for phony

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) //...

Member Avatar for tinstaafl
0
959
Member Avatar for Bendez Thyna
Member Avatar for Bendez Thyna
0
324
Member Avatar for OnceUponaDime
Member Avatar for necrovore
Member Avatar for necrovore
0
2K
Member Avatar for Dragos_1

Didnt like your [downvote](http://stackoverflow.com/questions/29375458/c-minimum-distance-between-cities-and-minimum-travel-time-error)?

Member Avatar for Schol-R-LEA
0
756
Member Avatar for NathanOliver

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 …

Member Avatar for DaveAmour
0
234
Member Avatar for Mayukh_1

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 …

Member Avatar for NathanOliver
0
309
Member Avatar for soe win
Member Avatar for DS9596

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 …

Member Avatar for tinstaafl
0
163
Member Avatar for Baba Ki
Re: 42

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)

Member Avatar for iamthwee
-2
112
Member Avatar for AQ

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 …

Member Avatar for NathanOliver
0
250
Member Avatar for Bendez Thyna

Did you try to [google](http://lmgtfy.com/?q=passing+arrays+to+functions+c%2B%2B) that?

Member Avatar for NathanOliver
0
108
Member Avatar for m..abdullah4

Please detail what the problem is, what you have tried to solve it and any errors you are getting with the code you have.

Member Avatar for NathanOliver
0
84
Member Avatar for ghalib951
Member Avatar for can-mohan

When doing operations like this you should look at using the [copy and swap idiom](http://stackoverflow.com/a/3279550/4342498).

Member Avatar for can-mohan
0
437
Member Avatar for DS9596

Does line 7:`int func(int);` look the same as line 22:`int func(int base, int power)`?

Member Avatar for David W
0
405
Member Avatar for daniel1977

This is why [proper indention](http://en.wikipedia.org/wiki/Indent_style) is so important.

Member Avatar for NathanOliver
0
207
Member Avatar for Mubashir_1

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)

Member Avatar for NathanOliver
0
40
Member Avatar for ghalib951
Member Avatar for nitin1

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 …

Member Avatar for serpi90
0
141
Member Avatar for shizu
Member Avatar for sheenalsingh

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 ;)

Member Avatar for mridul.ahuja
-1
165
Member Avatar for mohamed_49

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 …

Member Avatar for AkumaJack
0
232
Member Avatar for tentrabyte

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) …

Member Avatar for tentrabyte
0
310
Member Avatar for Surabhi_1

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.

Member Avatar for Surabhi_1
0
378
Member Avatar for Surabhi_1
Member Avatar for Surabhi_1

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.

Member Avatar for NathanOliver
0
138
Member Avatar for William Hemsworth

@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).

Member Avatar for William Hemsworth
0
357
Member Avatar for obinaysamanoden

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.

Member Avatar for bernardo.mclobo
0
173
Member Avatar for Shamar_1

Just another person hoping that the internet is the answer to all of lives problems.

Member Avatar for David W
-2
172
Member Avatar for TObannion

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 …

Member Avatar for NathanOliver
0
329
Member Avatar for mike_2000_17

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 …

Member Avatar for NathanOliver
7
2K
Member Avatar for surya777

@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.

Member Avatar for NathanOliver
0
144
Member Avatar for pdk123

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. …

Member Avatar for NathanOliver
0
314
Member Avatar for nightcrew

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.

Member Avatar for omgerg
0
3K
Member Avatar for Mahbeezzy

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

Member Avatar for TObannion
0
192
Member Avatar for phony

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 …

Member Avatar for NathanOliver
0
488

The End.