Salem commented: Yes, that's it. +18
lol.... that's C not C++
What do you expect it to do? Assign "foo" to the class that's in Foo, or call it's constructor (like I did in the second code example)?
class Foo {
public:
void SubFoo() { cout << "something"; }
};
int main() {
Foo foo;
foo.SubFoo();
}
edit: read the other part :x
you could do something like
class F { public: F() { cout << "something" << endl; } }
class Foo : public F { }
damn you daniweb, we can't delete posts? :(
system("start http://www.google.com");
or system("C:\\Program Files\\Mozilla Firefox\\firefox.exe");
>you delete[] m_Contents; since it was allocated onto the heap not str.
I think it's safe to assume that the point of this constructor is to allocate memory to m_Contents and initialize it. Releasing m_Contents seems kind of counter-productive at this particular point in execution. :icon_rolleyes:
oh, right... sorry about that I don't see the bigger picture in anything :P
Look at TinyXML or something, it's nicely done.
now that makes me want to code an xml parser... perhaps with XPath support...
you delete[] m_Contents;
since it was allocated onto the heap not str.
you want to read it? easy.
*ahem*
use an ifstream object on the file, read it into an event_info structure (like struct event_info { int something;string event;int x;int y; }
)
and simulate the events (mouse_event for mup/mdown, SetCursorPos() for move)
*walks away now*
You can write sprite-based RPGs in Javascript, one guy even made a (slow) 3D chess game in JS.
C++ is the preferred language for games, mainly for it's speed and efficiency.
Oh really now, did you have to necropost in a thread 3 years old?
Can u provide sample code plzzzz
Read the bottom link. It has example code, read it yourself.
Yeah, and you have more control over objects in C++. Pointers, references, whatever. They all allow you greater control over what you code.
On Windows you can just put the website on the command line and it will open in the default browser, i.e. system("http://www.google.com");
Mhm. That's the whole point, choose the language for the job. Java is better than C++ at string parsing, C++ is better than Java at low-level things, bit manipulating, memory stuff, games... whatever.
I keep repeating, don't I... :P Oh well.
/thread
>And Java is powerful and so is Assembly.
The point is Assembler and C++ are the most efficient, when written right.
>You can create languages from most any language. They are just mechanisms to convert text instructions to machine code.
But sometimes languages throw in useless ASM/binary code that makes it slow.
C++ is better than Java for some things - Java better for others, like string parsing.
The game industry uses C++ because it's one of the fastest languages, if you did the same game with Java I bet you wouldn't get the same fps.
why did I post here...
And that's why you must use binary mode for FTP when transferring files from *nix to windows/mac/dos, otherwise the binary data will be corrupted by CRLFs. (and I will never understand that. :))
@ those who aren't already using any version of Microsoft Visual Studio:
You n00bs... Why do you continue to you use third party compilers? If your even remotely into development, you all need to get Microsoft Visual Studio. If on *nix machines, get WINE, and then get MSVS. MSVS is by far the best development workstation for any developer. And for the love of god, don't f***ing complain about it costing too much money. <snipped URL>
And if your one of those 'ethical' people who are religously banned from downloading illegal torrents, get a job, and use your second paycheck to buy MSVS.~T3chn0logic
You're the n00b here ;)
MSVS is alright, but there is no best compiler.
try something like:
System::String^ ofnen = gcnew System::String("OPen");
System::String^ often = gcnew System::String("de|en");
System::String t = TranslatingService::TranslateLanguage::TranslateText(ofnen, often);
Remember, std::string
is C++-specific, System::String
is .NET-specific, and portable to the .NET languages (Managed C++ and C#).
like they said, you can't initialize variables inside the class declaration.
furthermore, you should use arrays instead of question<number>, like string question[4];
.
If you're talking about your program, post your code.
>change into:
wrong. It's not constant because it has expressions that change. Thus you need dynamic memory (allocated with new
) or a type that's managed automatically (like Narue said, std::vector
for example).
Right, Narue? *still needs to learn alot*
haha, you use standard C code for the first part then a C++-style cast for the function. You should just make it C,
int Crypt(char *szChar)
{
return (int)szChar[0];
}
Post the error...
>#ifndef MAIN_H
>#define MAIN_H
you put your #endif in main, it should go at the bottom of your header.
That would be ASCII, not ANSI ;)
you can mark the thread solved now.
No. It wants a System::String^ (note the ^)
But to solve the problem, you should use std::strings
C# doesn't have STL. .NET has System::String and all that.
What's the ^ for anyway?
Use code tags and we might help.
And you should really work on your code formatting. That looks terrible. ;)
Read my post in your other thread.
...
USE. CODE. TAGS.
CHANGE IT TO int canidate[5];
Well, lose the CString.
System::String value = "RegNo";
System::String key = "Dept";
System::String /* assuming */ getValue = ReturnValue(value, key);
Why didn't you read the replies you already got?
He obviously doesn't want to learn and can't google. :P
Yeah, STL is the better way to go for C++.
Also, use delete[] pointername;
instead of just delete.
And there's three problems with your if-statements:
1: == is the comparison operator, not =
2: "cnd1" is not a char, it's a string. canidates[] is a char array.
3: if canidates[] was a char string array, you'd need to use strcpy(), not the assignment operator.
Hey.
What's better, i++ or ++i? Well ++i returns the value after it's incremented, but which is faster? (not necessarily for int, user-defined types with operator++ overloaded too.)
I guess not - it still has garbage.
Did this test.
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int *nums = new int[10];
for(int i=0;i<10;++i) cout << i << ": " << nums[i] << endl;
delete [] nums;
system("PAUSE");
return EXIT_SUCCESS;
}
but like everything in c/c++ I'm sure it's compiler-dependant.
...
you're not going to finish it unless someone does it for you. but nobody will.
Oh lord, people wanting us to help with CS bots... no, you do your own work. Actually learn something.
I know Pyton and I'm bored, so here (done in 5 minutes, so...):
#include <cstdlib>
#include <iostream>
#include <ctime>
using namespace std;
int main(int argc, char *argv[])
{
srand(time(NULL));
int arand[3];
for(int i=0;i<4;++i) arand[i] = rand()%30;
cout << "Enter 4 numbers between 0 and 30." << endl;
for(int i=0;i<4;++i) {
int x;
cin >> x;cin.ignore();
if(x > 30 || x < 0) {
cout << x << " is above 30 / below 0!";
return 1;
}
bool won = false;
for(int w=0;w<4;++w) {
if(arand[w] == x) {
cout << "WINNER" << endl;
won = true;
break;
}
else {
cout << "LOSER" << endl;
//break; (do we need this? I dunno, didn't test it)
}
}
if(won == true) break;
}
cout << "the computers numbers were:" << endl;
cout << "---" << arand[0] << "---" << arand[1] << "---" << arand[2] << "---" << arand[3] << "---" << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
Yep. And experiment - if you have an idea you want to implement, start a new file and see if it works.
why the while loop? can't you just do something like
for(int i=0;i<10;++i) {
strArray[i] = ReceiveFromPipe();
}
?
well split() by default removes all whitespace/newlines, so pass it a specific delimiter, i.e.
string = "Hello,\nWorld"
print string.split(",")
try using FMOD.
When I first setup SDL I had to go through the includes and remove start_code.h / end_code.h from the includes. Bah.
well, you'd want to change your print function
void print()
{
cout <<"hello, my major is " << major;
cout << ", and my GPA is " << gpa << endl;
}
and, to set it, whenever you make your object you can do something like:
Student x;
x.major = "whatever";
x.gpa = 1.337;
Yes, you can, but you can't use using namespace std;
, i.e.,
#include <string>
std::string str = "whatever";
class string {
public:
std::string str;
};
string q;
I think :P