Search:

Type: Posts; User: thefroggy

Page 1 of 7 1 2 3 4

Search: Search took 0.02 seconds.

  1. Replies
    13
    Views
    7,378

    Actually, the increment is done first, then the...

    Actually, the increment is done first, then the indirection, then the assignment. You have to remember that the result of a post-increment expression is value of the operand before the increment:

    ...
  2. Replies
    2
    Views
    1,259

    The problem is that you're using memcpy() as if...

    The problem is that you're using memcpy() as if you had a two dimensional array when what you really have is an array of pointers to arrays.

    You'll have to loop through your array and copy them...
  3. To add on to what MrWizard mentioned,...

    To add on to what MrWizard mentioned, std::auto_ptr would probably best suit your needs.



    #include <iostream>
    #include <memory>

    class test {
    public:
    int x;
  4. Replies
    21
    Views
    2,057

    Check your for loops. You're overstepping your...

    Check your for loops. You're overstepping your array bounds.


    for(i=1;i<5;i++)

    should be


    for(i=0;i<4;i++)
  5. Replies
    8
    Views
    1,120

    jlou, I'm sure that you know what you are doing...

    jlou, I'm sure that you know what you are doing and that it is just a simple mistake on your part, but for the OP's benefit, I just wanted to fix the typos that may cause confusion in your program.
    ...
  6. Replies
    13
    Views
    6,793

    In that code, the comma is an operator. The...

    In that code, the comma is an operator. The comma would be a separator, for example, in a function call:


    printf("%s", buf);


    Edit:

    They key difference is that a comma (used either as...
  7. I compiled the code posted below. The only change...

    I compiled the code posted below. The only change I made was to correct the precedence for negation. It compiles and runs as expected on DevC++, MSVC 6 and GCC 3.2. You might want to make sure that...
  8. The for loop actually ends right here: if(...

    The for loop actually ends right here:


    if( ebuff[ie] == ']' ) {
    cout << "value of expression is: " << nst[ntop] << endl;
    return 0;
    }

    The real problem is this: negation only requires...
  9. You could also do something like this (makes the...

    You could also do something like this (makes the user list easier to update):



    #include <iostream>
    #include <cstring>
    using namespace std;

    int main()
    {
  10. Replies
    22
    Views
    5,311

    Yes, and the syntax is just as you have it. Say...

    Yes, and the syntax is just as you have it. Say you wanted to create a vector of pointers to int:


    int num = 10;
    vector<int*> vec;
    vec.push_back(&num);

    Just remember that the regular...
  11. Replies
    18
    Views
    5,312

    Incidentally, I just coded a very simple version...

    Incidentally, I just coded a very simple version of such an editor for my multiuser database server. Objects in the database can have functions (in my own scripting language) attached to them. I...
  12. Replies
    6
    Views
    981

    You seem confused. A class is a definition of a...

    You seem confused. A class is a definition of a type. You can only have pointers to objects of that definition-- not to the definition itself. You could say: "I have a pointer to an object of class...
  13. Replies
    7
    Views
    981

    It should have been: (*i).sock The member...

    It should have been: (*i).sock

    The member operator has higher precedence than the dereference operator so you have to use parens to make sure the dereference is done first.
  14. Replies
    4
    Views
    2,030

    Your book is incorrect. Constructors are only...

    Your book is incorrect. Constructors are only invoked when you are creating a new object. (The other cases you mentioned will use your type conversion constructor) In the case of assignment, you are...
  15. Replies
    4
    Views
    1,992

    Remove "class" from the following: class...

    Remove "class" from the following:


    class MyGlobalClass gClass;

    and


    extern class MyGlobalClass gClass;
  16. Replies
    5
    Views
    1,214

    That was a rather long-winded and poetic way of...

    That was a rather long-winded and poetic way of asking how the hell your computer kept running while you trashed its contents.

    The basic answer is this: when a program is run, the entire thing is...
  17. Replies
    24
    Views
    2,963

    Assignments are expressions-- they return the...

    Assignments are expressions-- they return the assigned value. If they didn't, you wouldn't be able to do things like a=b=c=3 in C.
  18. Replies
    3
    Views
    1,287

    Because Node is a templated struct so you must...

    Because Node is a templated struct so you must provide the type for instantiation.

    Node *tmp=new Node;
    should be

    Node<T> *tmp=new Node<T>;
    Otherwise, the compiler has no idea how you want to...
  19. Replies
    4
    Views
    1,658

    Here's an example expression parser I posted here...

    Here's an example expression parser I posted here a while back. It doesn't include support for variables or functions, but they could be added fairly easily.



    #include <locale>
    #include...
  20. Replies
    7
    Views
    1,042

    > How come it ran fine on my vc++ 6.0??? MSVC...

    > How come it ran fine on my vc++ 6.0???
    MSVC 6.0 should not be used to gauge anything involving expected or defined behavior (especially when the STL is involved).

    >EDIT: if we don't include the...
  21. Replies
    1
    Views
    1,967

    It's probably because you're passing a reference...

    It's probably because you're passing a reference to a temporary. Change your overload function to a const reference and it should work:


    ostream& operator<<(ostream & os, const node & n)

    Make...
  22. Replies
    19
    Views
    2,904

    Search the web for "natural language parsers."...

    Search the web for "natural language parsers." Many MUDs have very complex input parsers nowadays that let you do things like:

    > get the first green sword in the 2nd wood crate
    > sell it to bob
    ...
  23. Replies
    33
    Views
    8,031

    > Procedural C is generally much faster than OO...

    > Procedural C is generally much faster than OO C++.
    This is usually true. But it also usually has to do more with design than the language itself. The problem with OO C++ is that people get used...
  24. Replies
    7
    Views
    2,016

    > That I doubt. Have you tried to find a compiler...

    > That I doubt. Have you tried to find a compiler that works strictly with C?
    lcc is a rather popular compiler that works strictly with C. But that is really side-stepping the point of my post--...
  25. Replies
    7
    Views
    2,016

    > C and C++ are both well suited for games....

    > C and C++ are both well suited for games.
    Agreed. Just as an example of using C for games: I don't think John Carmack would ever touch a C++ compiler, and id software turns out some of the best...
Results 1 to 25 of 161
Page 1 of 7 1 2 3 4