Search:

Type: Posts; User: CPlus

Page 1 of 3 1 2 3

Search: Search took 0.01 seconds.

  1. Thread: GetKeyState()

    by CPlus
    Replies
    4
    Views
    22,235

    GetKeyState()

    Hello :)
    Quick question:



    while(1){
    if(GetKeyState(VK_SHIFT)<0){ //if SHIFT pressed
    cout<<"control "<<endl;
    if(GetKeyState('a')<0){ //if SHIFT is still being pressed and...
  2. Replies
    37
    Views
    9,161

    Where does the 'foo' come from? I see the 'bar'...

    Where does the 'foo' come from? I see the 'bar' declared for the string.

    Thanks :)
  3. Replies
    37
    Views
    9,161

    Thanks guys. Okay this is what I have so far: ...

    Thanks guys. Okay this is what I have so far:



    class IntStr
    {
    private:
    typedef enum { INTEGER, STRING, UNION } MyType; //INTEGER, STRING, UNION are defined into MyType
    ...
  4. Replies
    37
    Views
    9,161

    I just looked up a tutorial...

    I just looked up a tutorial and saw

    "These [operator] functions return a reference to the stream object so that these operators can be chained together ( e.g. cout << "the answer is" << i << endl;...
  5. Replies
    37
    Views
    9,161

    Oh I was hoping to relate to the mTypeInfo within...

    Oh I was hoping to relate to the mTypeInfo within the class. Overloading operators must be done outside of the class and referred to with friend, right?

    Is the operator>> incorrect because of the...
  6. Replies
    37
    Views
    9,161

    Thanks. Would it look something like this? ...

    Thanks.

    Would it look something like this?



    ostream &operator<<(ostream &output, IntStr intstr)
    {
    if (mTypeInfo == INTEGER)
    output << intstr.mInt;
  7. Replies
    37
    Views
    9,161

    Thanks, it works WhiteFlags. How do I use the...

    Thanks, it works WhiteFlags.

    How do I use the << operater on the IntStr type?

    I tried this:



    IntStr IntStr::operator<< (IntStr argument)
    {
  8. Replies
    37
    Views
    9,161

    In order to overload

    In order to overload <<
    would I do something like this:



    IntStr operator<<(const int index) //index number with associated element
    {
    return v.at(index);
    }
  9. Replies
    37
    Views
    9,161

    Can it be done with a union? I was using...

    Can it be done with a union?

    I was using struct because I noticed the compiler did not complain by doing



    vector<IntStr>


    before the struct IntStr was completed.
  10. Replies
    37
    Views
    9,161

    Yeah but I'm still learning things though. I'm a...

    Yeah but I'm still learning things though. I'm a C++ programmer since I use C++, but I never said I was good at it.
    I just take notes as I go along :)

    Is there a way to do this:



    #include...
  11. Replies
    37
    Views
    9,161

    I went ahead and added the constructors: ...

    I went ahead and added the constructors:


    struct IntStr
    {
    int i;
    IntStr(int x): i(x) {}

    string s;
    IntStr(const char* y): s(y) {}
  12. Replies
    37
    Views
    9,161

    Oh okay. This is where I'm lost. I don't know...

    Oh okay. This is where I'm lost. I don't know much about structures aside from their class-like nature.
    I don't know how to use constructors, but would a constructor look like this?



    struct...
  13. Replies
    37
    Views
    9,161

    Is there any way to do this? #include...

    Is there any way to do this?



    #include <iostream>
    #include <string>
    #include <vector>
    using namespace std;

    struct IntStr
  14. Thread: Vector Nesting

    by CPlus
    Replies
    10
    Views
    2,707

    Oh okay. I tried with 2 stars but it doesn't...

    Oh okay. I tried with 2 stars but it doesn't compile for some reason.



    string** a[2]; //visually : { a[0] , a[1] }
    a[0] = new string[2]; //visually : { {a[0][0],a[0][1]} , a[1] }
    ...
  15. Thread: Vector Nesting

    by CPlus
    Replies
    10
    Views
    2,707

    Is it possible to do something like this ...

    Is it possible to do something like this



    string* str[2]; //allows str[0] & str[1]
    str[0] = new string * [2]; //allows str[0][0] & str[0][1]
    str[1] = new string * [3]; //allows...
  16. Thread: Vector Nesting

    by CPlus
    Replies
    10
    Views
    2,707

    Is it possible to have jagged arrays using normal...

    Is it possible to have jagged arrays using normal arrays?
    Something like



    int i[2]; //makes i[0] and i[1]
    i[0] = new int[2]; //makes i[0][0], i[0][1]
    i[1] = new int[3]; //makes...
  17. Thread: Vector Nesting

    by CPlus
    Replies
    10
    Views
    2,707

    Vector Nesting

    Hello :)

    Is there a function (call it nest for this example) that nests vectors?

    Like this



    nest("char",3); //Result: vector< vector< vector<char> > >
    nest("string",2); //Result: vector<...
  18. Thread: Operator Problem

    by CPlus
    Replies
    1
    Views
    1,045

    Operator Problem

    Hello :)

    Is there a way to perform mathematical operations with the following custom datatype:



    #include <iostream>
    #include <string>
    #include <vector>
    #include <boost/variant.hpp>
  19. Oh no I didn't. Whoops. I will look into that...

    Oh no I didn't. Whoops. I will look into that right away.
  20. Replies
    37
    Views
    9,161

    Thank you LaserLight and Elysia for your points. ...

    Thank you LaserLight and Elysia for your points. It's true that C++ isn't making this easy :p .
  21. Inputting a dynamic, mutable character array with spaces

    Hello :)

    This is to anyone who needs the following:

    Dynamic array (the size is defined at run-time)
    Mutable array (the characters within the array can be edited)
    Spaces allowed (the input...
  22. Replies
    37
    Views
    9,161

    Yeah you both have good points there. To be...

    Yeah you both have good points there.

    To be honest, I don't actually have any concrete projects in mind. I'm trying to learn many ways to go about doing things in case I need them in the future...
  23. Replies
    37
    Views
    9,161

    This is probably a sinful answer amongst you...

    This is probably a sinful answer amongst you guys, but the simplest answer is...

    Because I'm lazy :p
  24. Replies
    37
    Views
    9,161

    Looking at this portion: ...

    Looking at this portion:


    c.push_back(IntStr(123, "abc"));

    cout << c.at(0) << endl;


    Is there any way to extract IntStr's individual parameters?
  25. Replies
    37
    Views
    9,161

    Vector of Structure

    Hello :)

    Is there any way to do this?
    (Green is working code, Red is non-working code)



    int main()
    {
Results 1 to 25 of 68
Page 1 of 3 1 2 3