1,288 Posted Topics
Re: Create a class with a pointer member. Allocate some memory with some data in it for the pointer to point to. In the class destructor, deallocate that memory. Now create a copy of that class. The pointer is copied. This is a "shallow" copy; you have copied only the pointer … | |
Re: There is no way for the function to ever get to line 9. It will never display the value of `a`. `go(2)` will return 2. https://ideone.com/0IhzzH | |
Re: The order that function parameters are evaluated is unspecified behavior. Different compilers can do it in different ways, and this is a mess of side effects as the parameters are evaluated. The only way to know for sure what's happening in this situation is to take apart the generated executable … | |
Re: If the input is 223322, what should the output be? 23 or 232? | |
Re: The function strcmp takes two parameters. Both of them have to be `char*`. Pointers to `char`. In this case: `strcmp( CL[j].nomC , cl)`, `cl` *is* a `char*`, so that's fine, but `CL[j].nomC` is *not* a `char*`. Is it a single `char`. What you're trying to do here could never work. … | |
Re: `start:` I look at this and I just KNOW you're planning to use a goto. There are situations in which goto is appropriate. This is NOT one of them, and this is not the year 1950. We have control statements now. http://www.cplusplus.com/doc/tutorial/control/ ` if( c == addition)` This shows a … | |
Re: The account_balance is what you're trying to change, right? So here are all the lines in your code where the account_balance is changed: Line 15: `account_balance=acc;` Line 19: `account_balance=0;` So where in your function `credit` do you think you are changing `account_balance`? | |
Re: Line 76, `invoice In();` , is stating that a function exists named `In` that takes no input parameters and returns an object of type `invoice`. Did you mean that, or are you trying to create an `invoice` object named `In`? | |
Re: Generate a random number from 1 to 100. Output that number, generate another one. Repeat until the generated number is 100. This is pretty bad code. Firstly, it's including `conio.h`, which is non-standard and from thirty years ago. It's not actually using anything from conio, so whoever put that there … | |
Re: So that we don't have to write out the same code over and over and over to make it work with every different type. We write the template once, and then the compiler makes it work for int and double and float and char and string and your own classes … | |
Re: Let's find out. http://www.cplusplus.com/reference/istream/istream/ignore/ So this function has default arguments. If you give no arguments, it's as if you gave `cin.ignore(1, EOF);` So it will take (and ignore) one character from the input sequence. | |
Re: If you're taking advice, don't use `conio.h`. It's non-standard and really not necessary (and you're not even using anything from it, so you've no reason to include it here). I see you've put this in the C++ forum, but you are clearly coding in C. Is that deliberate? Anyway, you … | |
Re: `return size.getArea(width,length).getFeet() * cost;` Let's take a look at this. So, you've got `size`, which is an object of type `RoomDimension`. And you're calling the class function `getArea` on it, like this: `size.getArea(width,length)`. And that class function, `getArea()`, will be returning something. What kind of object does it return? Because … | |
Re: You're not testing for it being closed; you're testing for the stream having an error flag set. http://www.cplusplus.com/reference/ios/ios/operator_bool/ How about if you use the `is_open` class function instead? http://www.cplusplus.com/reference/fstream/fstream/is_open/ | |
Re: Early incarnation of what we think of as objects can be traced to the fifties, and in the sixties there were certainly many languages making use of them. OOP predates C++ by a great many years. | |
Re: Undefined reference means that the linker is looking for a function, but it can't find it. This usally happens for one of two reasons: 1) You haven't linked to the right library. Not relevant here. 2) You haven't written it. That's the case here. In your header file, you promised … | |
Re: You're trying to read or write memory that isn't yours. If you want nay more information, we'll need the code. | |
Re: Show us what you typed, and what you got back. | |
Re: I interpret it as meaning that the function used to get the wins should be a parameter-less function, which means it takes in no parameters. int wins() { int value; cout << "Please input the number of wins" << endl; cin >> value; return value; } | |
Re: Somewhere there is a library containing the compiled code that is the actual function `fastICA`. You're not linking to it. You should be. You need to tell your IDE (which I'm guessing is some Visual Studio version) where the library is, and that you want to link to that library. … | |
Re: Since those output lines are in a loop that will run forever if `wlist` never empties... | |
Re: LPSTR is a windows typedef for a void\*. To cast a pointer from one type to another, put the type you're casting it to in front of it: `(char \*) HeapAlloc( ...` This will cast the LPSTR returned from HeapAlloc to a char\*. It's up to you to make sure … | |
Re: This `it = glist.erase(it);` moves the iterator to the next element, so if you do this, you should *not* increment the iterator again at the end of the loop. Move the `it++` out of the for loop header and do it yourself only if x did not == 0. | |
Re: Given that the loop will run forever if `wlist` is never empty, and it runs forever, I'd guess that `wlist` never empties. | |
Re: You are not telling your linker which libraries to look in. Find the right library on your Mac (I'm guessing the Boost regex library) and tell your linker about it. | |
Re: If you are allowed to assume that these are C-style strings that will use a zero value to mark the end, the function you're looking for is `strlen`. | |
Re: Tell us the first error. | |
Re: There are eight lines to read in the text file but your input loop goes around nine times. | |
Re: You're putting an extra line-ending in the middle of every line. | |
Re: It's more common to put your header guards *inside* the header file, and all the standard headers will *already* have header guards. | |
Re: `System::Console::WriteLine` is C# (and probably various other .NET langauges). You're trying to code in C++, right? You can't use constructs from entirely different programming languages. In C++, simple console output is done with `cout`. http://www.cplusplus.com/doc/tutorial/basic_io/ | |
Re: Every time you create a Person object, get some memory with `new`. Then `name` points at that memory. You need to `delete` that memory at the right time. A good way to do this is to create a constructor and destructor for your struct. Something like this struct Person{ char … | |
Re: Do you want to learn windows programming (using the Win32 API), or do you want to learn how to make GUIS? | |
Re: Long story short, you can't alter the text file. You can add new things to the end of the text file, but if you want to delete parts of it or change it, you can't. You have to create a whole new text file and delete the old one. | |
Re: What is your fnuction `freq` meant to do? I note that you ask the user to enter a value, but you don't actually take any input from them. | |
Re: cout << " * " << endl; cout << " * * * " << endl; cout << "* * * * *" << endl; cout << " * * * " << endl; cout << " * " << endl; | |
Re: Your code above defines the Account object. if you want to create one of these, here is how you can create one. `Account firstAccount;` If you want to create another one: `Account anotherAccount;` How about if you want to create a third? `Account thirdAccount;` If you want lots of Account … | |
Re: It's not about having to set `s` to NULL. It's because when you have a static member of a class, you have to specifically create that static variable somewhere. On line 23, you create the variable `s` that will be shared by all instance of the class. If you don't … | |
Re: In netBeans, Tools -> Options -> Editor -> Code Completion shows the code completeion settings. | |
Re: `variable_type name_of_variable;` For example, `int x; // an int variable, named "x"` | |
Re: #include <iostream> int main() { do { std:: cout << "2,3,5,7,11,13,17,19,23,29" std::endl; } while (false); } | |
Re: What input are you using? What is `argv[1]` in this case? | |
Re: What does strong mean? What does weak mean? What is a valid password? | |
Re: You're meant to make an array of 10 of them. `MyStruct anArrayOfTen[10];` | |
Re: It's wrong. It's an approximation that assumes every month has 30 days. | |
Re: > How do I initialize a struct then? Same way as everything else. Give it some values. ![]() | |
Re: Line 51, third parameter expects to be a `double miles[][days]` but you're trying to call a function on line 32 that expects a `double milesDays[days]` |
The End.