1,288 Posted Topics

Member Avatar for lewashby

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 …

Member Avatar for Moschops
1
170
Member Avatar for Mahnoor_1

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

Member Avatar for Mahnoor_1
0
174
Member Avatar for aravindm

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 …

Member Avatar for Moschops
0
202
Member Avatar for aravindm
Member Avatar for Kasxar
Member Avatar for khalid_5

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

Member Avatar for David W
0
256
Member Avatar for danila726

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

Member Avatar for Moschops
0
355
Member Avatar for siddy
Member Avatar for Mahnoor_1

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

Member Avatar for Mahnoor_1
0
226
Member Avatar for Mahnoor_1

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

Member Avatar for Mahnoor_1
0
838
Member Avatar for AQ

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 …

Member Avatar for basit_3
0
150
Member Avatar for basit_3

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 …

Member Avatar for Moschops
0
178
Member Avatar for basit_3

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.

Member Avatar for Moschops
0
194
Member Avatar for niski

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 …

Member Avatar for niski
0
227
Member Avatar for kiail

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

Member Avatar for kiail
0
232
Member Avatar for tgreiner

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/

Member Avatar for Moschops
0
792
Member Avatar for Curious Gorge

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.

Member Avatar for Frederick2
0
468
Member Avatar for kww228

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 …

Member Avatar for Moschops
0
1K
Member Avatar for dbfud1988

You're trying to read or write memory that isn't yours. If you want nay more information, we'll need the code.

Member Avatar for dbfud1988
0
302
Member Avatar for Farhan_8
Member Avatar for sunshine1020

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

Member Avatar for sunshine1020
0
717
Member Avatar for danibootstrap

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

Member Avatar for Moschops
0
337
Member Avatar for Baalla

Since those output lines are in a loop that will run forever if `wlist` never empties...

Member Avatar for Baalla
0
264
Member Avatar for danibootstrap

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 …

Member Avatar for Moschops
0
808
Member Avatar for Baalla

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.

Member Avatar for Moschops
0
357
Member Avatar for Baalla

Given that the loop will run forever if `wlist` is never empty, and it runs forever, I'd guess that `wlist` never empties.

Member Avatar for Baalla
0
161
Member Avatar for cannon_1

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.

Member Avatar for rubberman
0
808
Member Avatar for nicky nelson

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

Member Avatar for David W
0
195
Member Avatar for liyanaddsce
Member Avatar for TObannion

There are eight lines to read in the text file but your input loop goes around nine times.

Member Avatar for TObannion
0
261
Member Avatar for Ku Nj
Member Avatar for Mayukh_1
0
192
Member Avatar for newprogramming
Member Avatar for Curious Gorge

It's more common to put your header guards *inside* the header file, and all the standard headers will *already* have header guards.

Member Avatar for Curious Gorge
0
262
Member Avatar for Aeonix

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

Member Avatar for Aeonix
0
23K
Member Avatar for nhiap6

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 …

Member Avatar for Moschops
0
172
Member Avatar for Fon_1

Do you want to learn windows programming (using the Win32 API), or do you want to learn how to make GUIS?

Member Avatar for Moschops
0
215
Member Avatar for lp94

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.

Member Avatar for ddanbe
0
227
Member Avatar for rose_2

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.

Member Avatar for tinstaafl
0
147
Member Avatar for shafiqkuidad

cout << " * " << endl; cout << " * * * " << endl; cout << "* * * * *" << endl; cout << " * * * " << endl; cout << " * " << endl;

Member Avatar for basit_3
0
251
Member Avatar for Fares_1

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 …

Member Avatar for ddanbe
0
163
Member Avatar for nitin1

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 …

Member Avatar for deceptikon
0
335
Member Avatar for markdean1989
Member Avatar for Moschops
0
202
Member Avatar for Gayesha

`variable_type name_of_variable;` For example, `int x; // an int variable, named "x"`

Member Avatar for Moschops
-1
52
Member Avatar for A. Gregory

#include <iostream> int main() { do { std:: cout << "2,3,5,7,11,13,17,19,23,29" std::endl; } while (false); }

Member Avatar for David W
0
181
Member Avatar for Bartosz
Member Avatar for Bartosz
0
3K
Member Avatar for hadisur_rahman
Member Avatar for Syed Ammar

You're meant to make an array of 10 of them. `MyStruct anArrayOfTen[10];`

Member Avatar for Moschops
0
233
Member Avatar for hadisur_rahman
Member Avatar for rubberman
-1
241
Member Avatar for CodeWarrior14

> How do I initialize a struct then? Same way as everything else. Give it some values.

Member Avatar for jencas
0
177
Member Avatar for Kenneth_3

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

Member Avatar for Kenneth_3
0
165

The End.