1,288 Posted Topics

Member Avatar for nitin1

Now that we have C++11, which comes with threads, we no longer need anything platform specific. The best book on threading with C++11 I've found is the Anthony Williams book "C++11 Concurrency in Action". Williams' company has been selling a threading library for years and he really knows his stuff, …

Member Avatar for Moschops
0
164
Member Avatar for Vincent_5
Member Avatar for rubberman
0
220
Member Avatar for khalil je

for (;;) { cout << "|* * * * * *|---------------------|" << endl; cout << "| * * * * * |---------------------|" << endl; cout << "|* * * * * *|---------------------|" << endl; cout << "| * * * * * |---------------------|" << endl; cout << "|---------------------------------|" << endl; …

Member Avatar for Moschops
-1
97
Member Avatar for lewashby

> I'm starting to hate the idea of OOP. OOP is a way of thinking about and structuring code. Your problems above are all with syntax.

Member Avatar for rubberman
0
215
Member Avatar for lewashby

> if the structure were a class In C++, a struct IS a class. A class IS a struct. The only difference is the default member visibility (and related default inheritance). Everything you know about a class in C++ you also know about struct, because they're the same thing.

Member Avatar for cheryllocascio
0
195
Member Avatar for HuePig

A vector springs to mind: /*Item.h handles the item in game*/ #ifndef ITEM_H #define ITEM_H #include <string> #include <vector> class Item { public: Item(std::string IDesc, std::string IName) : name(IName), desc(IDesc), used(false){}; ~Item(){}; bool useable(){ return !used; } void useItem(){ used = true; } std::string getName() const { return name; } …

Member Avatar for HuePig
0
117
Member Avatar for LucasMNF55

Debug your code. Output the value of `pass` and `fpass` at the start, and each time you think they should (or may) have changed.

Member Avatar for LucasMNF55
0
267
Member Avatar for nitin1

Mike explains it heres https://www.daniweb.com/software-development/cpp/tutorials/466177/understanding-c-from-source-to-binaries in the section headed "Dynamic vs. Static Libraries"

Member Avatar for nitin1
0
163
Member Avatar for Suzie999

You can. However, what do you actually need from the image library? If you just need to be able to read images into memory, and write them again afterwards, and you'll do the manipulation yourself, ImageMagick might be a bit overpowered. There are many, many image libraries available.

Member Avatar for Suzie999
0
399
Member Avatar for anumash

> Shouldn't there be a conflict? No. I agree, that you *could* create a programming langage in which you wouldn't be allowed to create two objects with the same name in the way that you can in C and C++, but that's not how C and C++ were designed. In …

Member Avatar for rubberman
0
251
Member Avatar for Transcendent
Member Avatar for prahesh
Member Avatar for prahesh
0
461
Member Avatar for PK.AMRAV

You've got a function named main somewhere else as well. Perhaps you are compiling this code and some other code into the same program.

Member Avatar for deceptikon
0
246
Member Avatar for EarhawkPH

What do you mean when you say "i've done atleast 4 programs"? Do you mean that you have four separate programs, all compiled and linked and reay to run (and you can run each of them separately right now), and you want to write a new program that will start …

Member Avatar for dinad578
0
778
Member Avatar for Mr.M

Add `#include <stdafx.h>` to your code. Before whatever you had to include to get this error.

Member Avatar for Moschops
0
90
Member Avatar for andrew mendonca

I've spotted a pattern to your questions. You write something that compiles, then when it turns out to be wrong, you come here and ask us to do your homework for you. Perhaps you should be putting a bit more effort into thinking about the problems and, more importantly, testing …

Member Avatar for Moschops
0
190
Member Avatar for singersongrita

A vector of strings comes to mind. `vector<string> stringStore;` Every time you need to add one, just add it to the end of the vector `stringStore.push_back(nextString);` Similarly for `double` values.

Member Avatar for hAbbas
0
328
Member Avatar for hkumar1993

Generally, if you cannot open a file that does exist, it's because you're not looking in the right place. Start by replacing the filename with the complete path and see if that works. If it does, you know that your program is looking in the wrong place. How do you …

Member Avatar for hkumar1993
0
2K
Member Avatar for Sarkurd

In your header file, you promised that *you* would be writing the default constructor. Like this: `Captain();` So because you made that promise, you have to write a default constructor of this form: Captain::Captain() { } but you didn't. So the compiler complains that it can't find the default constructor …

Member Avatar for Sarkurd
0
191
Member Avatar for lewashby

We would be remiss if we did not point out that `rand` is deprecated and really should not be used. Some of the implementations of it are fist-bitingly bad. http://channel9.msdn.com/Events/GoingNative/2013/rand-Considered-Harmful Welcome to C++11's bright world of <random> :)

Member Avatar for deceptikon
0
216
Member Avatar for tentrabyte
Member Avatar for HuePig

> Am I going on this the wrong way?? Yes. To begin with, it doesn't make any sense to me that a RoomOne is a kind of StoneAdventure (and that's what inheritance does; if X inherits from Y, then X *is a* specialised kind of Y, and can be used …

Member Avatar for HuePig
0
205
Member Avatar for furalise

` cout << mychar << endl;` This line is passing a char pointer to `cout`. When `cout` is given a char pointer to operate on, the function executed looks like this: Output the char being pointed to, and the next char, and the next, and so on, until you find …

Member Avatar for Moschops
0
228
Member Avatar for Muhammad_42
Member Avatar for muhammad.husnain.5099
Member Avatar for CairBear1

Your code is littered with odd symbols. Like the one at the satrt of line 4. No idea what they're doing there. Get rid of them. In your code, every time you have one of these `{` you're going to need one of these `}`. You're missing lots. At the …

Member Avatar for Hiroshe
0
192
Member Avatar for andrew mendonca
Member Avatar for Sarkurd

`gpof EXECUTABLE-FILE gmon.out > outfile.txt` Your command line doesn't have the executable filename.

Member Avatar for Sarkurd
0
363
Member Avatar for tentrabyte

I'm not going to do your homework for you, but here is a way to output a char's numerical respresentation: `std::cout << (int)someChar;`

Member Avatar for Neuman
0
109
Member Avatar for lewashby
Member Avatar for EarhawkPH

Even a four byte unsigned long int has a range of 0 to 4,294,967,295. This is more than 4 billion and more than a hundred thousand. Unless you're using a PC from a very long time ago (decades ago), your long ints are at least this big. So what is …

Member Avatar for sanjulovers
0
250
Member Avatar for new_developer

If you have a modern compiler, you can do something like this to initialise class members: ` vector<int> vec = vector<int>(5); `

Member Avatar for Moschops
0
542
Member Avatar for tan.revilleza

#include <iostream> int main() { while(1) { std::cout << "1" << std::endl << "12" << std::endl << "123" << std::endl << "1234" << std::endl << "123" << std::endl << "12" << std::endl << "1" << std::endl; break; } }

Member Avatar for Sam_6
-1
261
Member Avatar for cambalinho

Reading binary image files and getting the data from them is not simple. For some formats, like JPG, it's really not simple. Unless you're doing this because you really want to know baout how the information is stored in the file formats, just use an image library. It's what everyone …

Member Avatar for mike_2000_17
0
558
Member Avatar for lewashby

A simple static library is a bunch of ".o" files, stuck together. You need to read Mike's overview: https://www.daniweb.com/software-development/cpp/tutorials/466177/understanding-c-from-source-to-binaries

Member Avatar for rubberman
0
144
Member Avatar for Ivzirnalsradeys

> if you cant help so please @priteas so please staw away from other buisness I think you need to rephrase that. Try something like this: > I need to give three advantages of using procedures. I'm not sure exactly what the question is asking. I think that a procedure …

Member Avatar for rubberman
-2
236
Member Avatar for salafiyya1

Without using a library, you're simply going to have to do it yourself. Frankly, you need to start by thinking rather than coding. You can read the xml file easily. Open it, read in data. But that just gets you a lot of strings. How do you intend to organise …

Member Avatar for rubberman
0
374
Member Avatar for davecoventry

`#include "action.cpp"` This tells the preprocessor to paste the contents of the text file "action.cpp" into this position, just as if you had yourself manually typed it in at that position. So, you have a definition of the function in action.cpp, and a definition of the function in main.cpp This …

Member Avatar for davecoventry
0
5K
Member Avatar for Mr.M

The linker can't find those functions. Assuming you've not got the names of the functions wrong, and that they're library functions, you need to make sure you have the library containing those functions, and make sure you have told the linker what those libraries are named, and make sure you …

Member Avatar for Mr.M
0
144
Member Avatar for gesha

The `mode` average is the value that comes up most frequently. Get all the values, look at each one in turn, and count up how many of each there are.

Member Avatar for David W
0
2K
Member Avatar for iqra aslam

Here is a link presenting various options. Decide now which operating system you're using (windows or other), and decide if you want an IDE or if you want to do your own compiling/linking, and then pick one from the list. http://www.cplusplus.com/articles/j8hv0pDG/

Member Avatar for mike_2000_17
-1
230
Member Avatar for joel_3
Member Avatar for Nikolas9896

If the compiler (actually pre-processor in this case) cannot find a file it is looking for, then you have not told it where to look, or put the file in the wrong place, or misnamed the file. What is the exact error message?

Member Avatar for Nikolas9896
0
370
Member Avatar for Mr.M

Depends on your version of Visual Studio. http://stackoverflow.com/questions/2676417/how-do-include-paths-work-in-visual-studio

Member Avatar for Mr.M
0
188
Member Avatar for Joemeister

C++ strings come with functions to find substrings inside them. http://www.cplusplus.com/reference/string/string/find/

Member Avatar for マーズ maazu
0
920
Member Avatar for amithunter
Member Avatar for brent.banaag

You have a pointer, `fp`, that you create and use but you never, ever set it to anything. It will be pointing to some random location in memory. This is very bad.

Member Avatar for Moschops
0
165
Member Avatar for Joemeister

`startingExpr[i]` is a char, and `newChar` is a string, so `startingExpr[i] = newChar;` makes no sense; you're trying to assign a string object to a char. This being C++11, we have a to_string function now for converting an int to a string: http://en.cppreference.com/w/cpp/string/basic_string/to_string

Member Avatar for iamthwee
0
298
Member Avatar for Joemeister

> conversion from 'std::stack<int>*' to non-scalar type 'std::stack<int>' requested `stack<int> resultStack = new stack<int>();` The bit on the right gives you a *pointer* to a `stack<int>`. You're trying to store that pointer value as a `stack<int>` object. This makes no sense. A `stack<int>*` is not the same as a `stack<int>` …

Member Avatar for iamthwee
0
331
Member Avatar for Yahia Farghaly

I see you changed your question; first, you asked about this: `foo&(){...` and then you changed that to this: `int& foo(){...` Presumably, the first one was a typo. In C++, the second *is* invalid (and the first, but I'm callign that a typo). You *can*, however, return a **const** reference …

Member Avatar for Moschops
0
451

The End.