202 Posted Topics

Member Avatar for np2100

As others have said - there is no change in syntax when using an API. You need to learn about C++ before you learn how to perform specific output with it (ie, a GUI). However, its very difficult to learn C++ when you have no means of outputting data. That's …

Member Avatar for yap.nice
0
133
Member Avatar for Wiki_Tiki

#2: if you don't know how to do that, use [URL="http://www.cplusplus.com/reference/iostream/ifstream/"]ifstream[/URL] to read from files and [URL="http://www.cplusplus.com/reference/iostream/ofstream/"]ofstream[/URL] to write to them (or just [URL="http://www.cplusplus.com/reference/iostream/fstream/"]fstream[/URL] for both). Quick example: [CODE] #include <fstream> using namespace std; int main() { int data = 5; ofstream fout("myfile.txt"); fout << data; fout.close(); int moreData; ifstream …

Member Avatar for Wiki_Tiki
0
102
Member Avatar for edel
Member Avatar for CoolGamer48
0
297
Member Avatar for Malwarehunter94

I used to use GameMaker. There used to be tutorials on the site, but GameMaker got bought by YoYo games, so I'm not sure if they're anywhere anymore. Ill see if I have any saved on my computer somewhere if I have the time. A nice thing about GMaker is …

Member Avatar for ripsocrates
0
147
Member Avatar for brk235

That's more of a math question than a C++ question. At any rate, I believe it has something to do with the Pythagorean theorem. The 2D distance formula is sqrt((x2-x1)^2 + (y2-y1)^2) = D. I'm unsure what the 3D equation is.

Member Avatar for HarryGabriel91
0
105
Member Avatar for clutchkiller

I don't really think it would make sense to learn one without sort of learning the other. I mean they're mostly the same. When you begin to learn either language, you're going to cover basic flow control - if statements, loops, functions, etc. It's only when you get to classes …

Member Avatar for Ancient Dragon
0
113
Member Avatar for kneiel

Just because IBM says something is wrong doesn't mean VC++ agrees. Heck, VC++ could make [ICODE]billybob[/ICODE] a primitive data type and still call itself a C++ compiler (though few others would agree - and that's really what matters). Whatever is in the ISO standard for C++ is what is allowed. …

Member Avatar for kneiel
0
134
Member Avatar for CoolGamer48

I'm writing a program for a contest (it's a demo, not the actual thing - so I'm not cheating by asking for help - and my question isn't directly related to the algorithm they want anyway). To submit a program, you send them the .cpp file, and they execute it …

Member Avatar for CoolGamer48
1
135
Member Avatar for DanDaMan

Post the header file and the .cpp file. There's no specific special thing you need to do to create a header file. What you said could be correct, but it's a bit vague.

Member Avatar for DanDaMan
0
160
Member Avatar for coveredinflies

The address of a variable returned by the reference operator (&) is not an l-value, meaning you can't put it on the left side of an assignment operator. Besides, why would you want to?

Member Avatar for coveredinflies
0
187
Member Avatar for bramprakash1989
Member Avatar for CoolGamer48
0
96
Member Avatar for charlinjoe

Do you mean manually deleting data at an address you chose? Or are you just asking what delete does? [CODE] int* x;//declare a pointer to an it x = new int;//create an int somewhere in memory and store its address in x *x;//access the actual int stored at the location …

Member Avatar for CoolGamer48
0
92
Member Avatar for Momar

One very evident difference between the two myNodes is that the second one will be deleted at the end of scope, while the pointer will continue to exist until you manually delete it. Well, that wasn't exactly true. The pointer myNode will be deleted at the end of scope, but …

Member Avatar for CoolGamer48
0
152
Member Avatar for kinger29

I think what he's referring to in #1 is a NULL pointer: [CODE] int* x = NULL; //or int* x = 0; [/CODE] I'm guessing this is what is meant by #3: [CODE] int x[10] = {0}; x[3] = 5; x[4] = 13; int* pInt = (&x[3])+1; [/CODE] *pInt would …

Member Avatar for Salem
0
310
Member Avatar for Manutebecker

>>numInstances[7] would be the number of times 7 showed up shouldn't numInstances[6] be the number of times 7 was rolled? Like n1337 said, you should do: [CODE] numInstances[sum-1]++; [/CODE] otherwise, you'd be wasting numInstances[0], and when you roll a 12, you'd have nowhere to put it (since the highest index …

Member Avatar for VernonDozier
0
112
Member Avatar for sidatra79

The only insert function of the vector template I found takes two parameters - one of type size_t, and the other of type Item_type. When you call it, you're only specifying the Item_type parameter. Also, I believe the entire purpose of the VectorOfNotebooks class is to not have to use …

Member Avatar for sidatra79
0
211
Member Avatar for cam875

To my knowledge, both DirectX and OpenGL are written with C or C++. You could write an API like them yourself using C++. On Windows, you can use SetPixel() to set a pixel on a screen. I believe that's one of the most basic graphical functions you can use (in …

Member Avatar for Tigran
0
102
Member Avatar for CoolGamer48

I'm having problems creating an array with a dynamic size using new. Here is the relevant code: [CODE] enum LandCondition { Bad, Good }; //... int IMG_WIDTH, IMG_HEIGHT; LandCondition* land; //... land = new LandCondition[IMG_WIDTH][IMG_HEIGHT];//causes errors [/CODE] The errors VC++ gives me are: error C2540: non-constant expression as array bound …

Member Avatar for CoolGamer48
0
110
Member Avatar for Wiki_Tiki

I myself have run into problems with side by side configuration, and while I don't fully understand it, it is not an issue with Vista. I've run into the same problem when moving an app from one xp machine to another.

Member Avatar for Tigran
0
142
Member Avatar for cam875

You don't even need Direct3D - the Windows API has your back: [URL="http://msdn.microsoft.com/en-us/library/ms532304(VS.85).aspx"]link[/URL]

Member Avatar for cam875
0
262
Member Avatar for QuantNeeds
Member Avatar for QuantNeeds
0
1K
Member Avatar for CoolGamer48

To my understanding, certain classes, like ifstream, have a conversion to a primitive data type, like bool. In other words, you can do this: [CODE] if((fin >> x) && done == false) //... [/CODE] Now, does this simply work because ifstream has the && operator overloaded, or can objects of …

Member Avatar for Prabakar
0
92
Member Avatar for pavel989

The code in header files is executed in the order you #include them. So if the code file1.h needs to be executed before the code in file2.h (for some reason), then they must be #included in that order.

Member Avatar for pavel989
0
144
Member Avatar for Motvel

[QUOTE=Motvel;657389]Thank you! But, tell me please, in the first method why the blank character (the space) is omited by default? Is there one error, or such work the method?[/QUOTE] The extraction operator >> skips over whitespace. To read a file character by character including whitespace, use the get() method. Though …

Member Avatar for Motvel
0
153
Member Avatar for Manutebecker

Why DirectX instead of OpenGL? Personally I use DirectX, but even if you don't mind DirectX being closed-source and platform-specific, you may still choose to use OpenGL.

Member Avatar for Tigran
0
138
Member Avatar for nikki123

[QUOTE=Salem;657073] > Develop a program in C++ Is that an [URL="http://web.comhem.se/hansdotter/romanes.html"]order?[/URL][/QUOTE] Are you not supposed to know Latin to find that funny?

Member Avatar for Salem
0
115
Member Avatar for CoolGamer48

Say I have a file file1.h: [CODE] namespace a { int Func() { return 5; } } [/CODE] and a file file2.h [CODE] #include "file1.h" namespace a { class Foo { Foo(); }; } [/CODE] and file2.cpp: [CODE] #include "file2.h" a::Foo::Foo() { Func();//<---- } [/CODE] Can Func() be referenced like …

Member Avatar for CoolGamer48
0
81
Member Avatar for Ccrobinson001

Have you compiled and run this? This: [CODE]avgNoOfGuesses=sum/noofgamesplayed;[/CODE] seems like it would generate an error, since noofgamesplayed is 0, and you're dividing by it. Besides, that statement and the one above it are unnecessary. Do you need to write the functions, or do you simply need to call them? Either …

Member Avatar for Ccrobinson001
0
238
Member Avatar for xxReYMaXxx

[QUOTE=robertmacedonia;656744]Man, I realise that you could solve the problem right away, I know you guys are experienced and these problems are too easy for you. I just wanted to help the dude like some of you guys helped me. And now that he's got the solution, he can look at …

Member Avatar for robertmacedonia
0
143
Member Avatar for cam875

Depending on your needs, you may also consider [URL="http://www.cplusplus.com/reference/stl/list/"]lists[/URL] or [URL="http://www.cplusplus.com/reference/stl/deque/"]deques[/URL]. Here's a reference for all STL containers: [URL="http://www.cplusplus.com/reference/stl/"]link[/URL]

Member Avatar for CoolGamer48
0
98
Member Avatar for CoolGamer48

In regard to good style, is it better to use the NULL macro, or should you just use 0? And should you cast either one to the type of pointer you're using? i.e.: [CODE] int* pInt = (int*)0;//this, int* pInt2 = 0;//this, int* pInt3 = (int*)NULL;//this, int* pInt4 = NULL;//or …

Member Avatar for ArkM
0
322
Member Avatar for CoolGamer48

A friend of mine recently asked me how one would convert a .bmp font to a .ttf. I said I was unsure, but it got me thinking to how I would code a program to do that. How would someone who wants to create a .bmp to .ttf converter go …

Member Avatar for ArkM
1
145
Member Avatar for danieldan

[QUOTE=Wiki_Tiki;655585][CODE]cout << " \n"; char letter; cout << "Enter a letter to end the program:\n"; cin >> letter; cout << "Goodbye.\n"; return 0; }[/CODE] I know this probably isn't going to be much help to you, but it's way easier and simpler to, instead of having to type a random …

Member Avatar for Wiki_Tiki
0
220
Member Avatar for xxjinseruxx

You might want to also add a check in converter() (or somewhere else) to make sure that the number of deaths is not 0.

Member Avatar for xxjinseruxx
0
998
Member Avatar for kinger29

C++ arrays are static in size, yes, but the Standard Template Library has containers that can do what you want. [URL="http://www.cplusplus.com/reference/stl/list/"]lists[/URL] sounds like they may fit your needs, but [URL="http://www.cplusplus.com/reference/stl/vector/"]vectors[/URL] or [URL="http://www.cplusplus.com/reference/stl/deque/"]deques[/URL] may also be of use. As far as this:[code]CStringArray MyArray[numData][/code] You need to use dynamic memory to allocate …

Member Avatar for Lerner
0
169
Member Avatar for coveredinflies

don't use char arrays or char*. use std::strings. if your input is a string, you can just use the [] operator to access elements in it (it's been overloaded) [CODE] string str = "Hello"; if(str[1] == 'e') //this is true [/CODE] If you really want to know how to convert …

Member Avatar for CoolGamer48
0
4K
Member Avatar for Lukezzz

Just so you know, the typedefs aren't necessary to do what you want... they just make it much easier. You had the right idea on your own. If this [ICODE]vector<string>[/ICODE] is a 1D vector, and this [ICODE]vector<vector<string>>[/ICODE] is a 2D vector, then following the pattern, you should've been able to …

Member Avatar for Nick Evan
0
2K
Member Avatar for gispe

Salem meant you should wrap your code in code tags (the (code) button on the top, or just type `YOUR CODE HERE`, with four spaces before code). Do you want the for loop to be part of this conditional: else if ((peso > 30) && (peso < 1000) && (dia …

Member Avatar for VernonDozier
0
148
Member Avatar for greyghost86

When you run the program, and you want to guess that your favorite food is pizza, do actually type in "pizza", or do you input 10?

Member Avatar for CoolGamer48
0
118
Member Avatar for dipumali
Member Avatar for CoolGamer48
0
69
Member Avatar for phouse512

[QUOTE=Salem;653469]C++ is a language, as defined by ISO. Visual C++ is an implementation (like Borland, GNU, Intel). Any modern 32-bit compiler will probably meet your needs for learning C++.[/QUOTE] Wait, so every compiler is considered to have it's own "implementation" of C++? So, is it possible to have a compiler …

Member Avatar for phouse512
0
248
Member Avatar for robertmacedonia

Google is very nice: [URL="http://msdn.microsoft.com/en-us/library/9yb20073(VS.71).aspx"]link[/URL] As others have said, post code, but this, or something like it, would cause the problem you're having: [CODE] void Func() { cout << "I am a function.\n"; } int main() { if(Func())//Func() returns nothing - you can't check if a nonexistent result is true …

Member Avatar for robertmacedonia
0
143
Member Avatar for klactose

To address your first issue: void pointers. Google it. It's basically a pointer that has no type bound to it. I haven't used them too much but I think they fit your needs. Your second problem: You can check to see if there is data to be read. Use the …

Member Avatar for klactose
0
6K
Member Avatar for rtwister

Post your errors, but at a glance: [CODE] void Mainmenu(); { string choice //missing semicolon //.... [/CODE]

Member Avatar for CoolGamer48
0
75
Member Avatar for gangsta gama

You need some [I]basic[/I] knowledge of the Windows API to use DirectX - so either way you should check this out: [URL="http://winprog.org/tutorial/simple_window.html"]http://winprog.org/tutorial/simple_window.html[/URL]. Buying books is a very good idea. I haven't read any books on the Windows API. A book on DirectX I did read was Beginning Game Programming, by …

Member Avatar for gangsta gama
0
130
Member Avatar for kux
Member Avatar for CoolGamer48

Is it bad to make a reference parameter optional by giving it a default value? Like here: [CODE]int Parse(std::string filename, std::string& error = (std::string)"");[/CODE] Here, the caller of the function may pass an optional std::string that will be filled with an error message if there is one. Is this considered …

Member Avatar for Duoas
0
106
Member Avatar for gispe

[ICODE]exp *= exp[/ICODE] when exp is 1 means [ICODE]exp *= 1;[/ICODE], [ICODE]exp = exp*1;[/ICODE], [ICODE]exp = exp;[/ICODE]. That increment does nothing. To increase exp by 1 every iteration, do [ICODE]exp += 1;[/ICODE], if that's what you meant. Also, what is exponente? What is it set to?

Member Avatar for gispe
0
73
Member Avatar for aecsant

Is this what you mean? [CODE=C++] #include <iostream> using namespace std; class Foo { public: Foo() { cout << "Foo constructor\n"; } }; class SubFoo : public Foo { public: SubFoo() { cout << "SubFoo constructor\n"; } }; int main() { Foo* myfoo = new SubFoo(); return 0; } [/CODE]

Member Avatar for Prabakar
0
261
Member Avatar for Jennifer84

Why are you doing [ICODE]this->Close();[/ICODE]? You can just say [ICODE]Close();[/ICODE] if you're within the scope of the function, can't you? (unless you're trying to specify that you're not referring to some external Close() function, but I don't see how the compiler would think you mean that over a member of …

Member Avatar for Jennifer84
0
223

The End.