hacker9801 49 Junior Poster

lol.... that's C not C++

hacker9801 49 Junior Poster

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

hacker9801 49 Junior Poster
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? :(

hacker9801 49 Junior Poster

system("start http://www.google.com");
or system("C:\\Program Files\\Mozilla Firefox\\firefox.exe");

hacker9801 49 Junior Poster

>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

hacker9801 49 Junior Poster

Look at TinyXML or something, it's nicely done.

now that makes me want to code an xml parser... perhaps with XPath support...

hacker9801 49 Junior Poster

you delete[] m_Contents; since it was allocated onto the heap not str.

hacker9801 49 Junior Poster

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*

hacker9801 49 Junior Poster

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.

hacker9801 49 Junior Poster

Oh really now, did you have to necropost in a thread 3 years old?

hacker9801 49 Junior Poster

Can u provide sample code plzzzz

Read the bottom link. It has example code, read it yourself.

hacker9801 49 Junior Poster
hacker9801 49 Junior Poster

Yeah, and you have more control over objects in C++. Pointers, references, whatever. They all allow you greater control over what you code.

hacker9801 49 Junior Poster

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");

hacker9801 49 Junior Poster

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

hacker9801 49 Junior Poster

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

hacker9801 49 Junior Poster

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. :))

hacker9801 49 Junior Poster

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

hacker9801 49 Junior Poster

Keep in mind you can still use .NET on Linux/Mac/Windows with Mono. ;)

hacker9801 49 Junior Poster

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#).

hacker9801 49 Junior Poster

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]; .

hacker9801 49 Junior Poster

If you're talking about your program, post your code.

hacker9801 49 Junior Poster

>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*

Salem commented: Yes, that's it. +18
hacker9801 49 Junior Poster

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];
}
hacker9801 49 Junior Poster

69% XD

hacker9801 49 Junior Poster

Post the error...

>#ifndef MAIN_H
>#define MAIN_H
you put your #endif in main, it should go at the bottom of your header.

hacker9801 49 Junior Poster

That would be ASCII, not ANSI ;)

you can mark the thread solved now.

hacker9801 49 Junior Poster

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?

hacker9801 49 Junior Poster

Use code tags and we might help.

And you should really work on your code formatting. That looks terrible. ;)

hacker9801 49 Junior Poster

Read my post in your other thread.

hacker9801 49 Junior Poster

...
USE. CODE. TAGS.

CHANGE IT TO int canidate[5];

hacker9801 49 Junior Poster

Well, lose the CString.

System::String value = "RegNo";
System::String key = "Dept";

System::String /* assuming */ getValue = ReturnValue(value, key);
hacker9801 49 Junior Poster

Why didn't you read the replies you already got?

He obviously doesn't want to learn and can't google. :P

hacker9801 49 Junior Poster

Yeah, STL is the better way to go for C++.

Also, use delete[] pointername; instead of just delete.

hacker9801 49 Junior Poster

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.

hacker9801 49 Junior Poster

Thanks, Duoas.

hacker9801 49 Junior Poster

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

hacker9801 49 Junior Poster

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.

hacker9801 49 Junior Poster

...
you're not going to finish it unless someone does it for you. but nobody will.

hacker9801 49 Junior Poster

Oh lord, people wanting us to help with CS bots... no, you do your own work. Actually learn something.

Salem commented: Well said +17
hacker9801 49 Junior Poster

If you're using PHP, see shell_exec().

hacker9801 49 Junior Poster

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;
}
hacker9801 49 Junior Poster

Yep. And experiment - if you have an idea you want to implement, start a new file and see if it works.

hacker9801 49 Junior Poster

why the while loop? can't you just do something like

for(int i=0;i<10;++i) {
   strArray[i] = ReceiveFromPipe();
}

?

hacker9801 49 Junior Poster

well split() by default removes all whitespace/newlines, so pass it a specific delimiter, i.e.

string = "Hello,\nWorld"
print string.split(",")
hacker9801 49 Junior Poster

try using FMOD.

hacker9801 49 Junior Poster

When I first setup SDL I had to go through the includes and remove start_code.h / end_code.h from the includes. Bah.

hacker9801 49 Junior Poster

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;
hacker9801 49 Junior Poster

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

hacker9801 49 Junior Poster

lol, thanks.