[C++] Begginer's questions

This is a discussion on [C++] Begginer's questions within the C++ Programming forums, part of the General Programming Boards category; Hello CP, I have a few questions regarding C++ programming. I have done proper research on them, but can not ...

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    2

    Question [C++] Begginer's questions

    Hello CP,

    I have a few questions regarding C++ programming. I have done proper research on them, but can not find adequate results.

    1.) In C++, can the 'switch' statement test chars, or strings? Example:
    case "Jeff":

    2.) Why, all of a sudden am I seeing an end brace with a semicolon on it? Example:

    struct jeffery
    {

    }; // <- Semicolon is required, why!?

    Thanks,
    -Jeff

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    1) Only "integral" types are allowed in switch, so things like "int", "char". If you're a math guy/girl, the reasoning for this would be that other types are "uncountable".

    2) I believe its just the syntax of defining a new struct type. Nothing special.

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    2
    Quote Originally Posted by nadroj View Post
    1) Only "integral" types are allowed in switch, so things like "int", "char". If you're a math guy/girl, the reasoning for this would be that other types are "uncountable".

    2) I believe its just the syntax of defining a new struct type. Nothing special.
    Thank you, made it a bit clearer =)


    My last question would be, what is the job market like for C/C++ programmers? (C++ specifically). I have heard working for companies such as Google, you sit around most of the day in a beanbag chair, etc...Other words, not a very serious environment. Could you enlighten me about the job market for C++?

  4. #4
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    Could you enlighten me about the job market for C++?
    Well thats certainly a broad question and discussion. Id recommend you post that in a separate thread, probably in the "General" or other relevant forum. Id suggest this because you'd get the most information that way (opposed to burried in this irrelevant thread).

    If a company wants people to enjoy their environment and want to attract people, describing it the way they do to the public is a great way to achieve this. This isnt to say that they dont actually have that environment (bean bag chairs, etc). It may seem "less professional", but that shouldnt deter you, considering its probably the biggest and most successful Tech company in history.

    I dont really know anything about the "C++ market" (or any other specific language-market). All I can say is that the "web development" market is much more open and probably easier to get a job in than doing C++ development, for example. That isnt to say that there isnt a "C++ market", of course we need developers in various languages, it just might be harder to get into.

    Of course these are mostly just my opinions (though some facts here), so dont base anything on just a few opinions.

  5. #5
    Registered User
    Join Date
    Apr 2006
    Posts
    2,041
    Quote Originally Posted by TechieJeff View Post
    2.) Why, all of a sudden am I seeing an end brace with a semicolon on it? Example:

    struct jeffery
    {

    }; // <- Semicolon is required, why!?

    Thanks,
    -Jeff
    Because C (and by extension C++) allows you to define a variable of a struct's type in the same line as you define the struct., like so:
    Code:
    struct StructName { char * members_go_here;} var1;
    struct AltStruct { char * members_go_here;} var2 = { "init"};
    struct AltStruct2 { char * members_go_here;} *var3 = &var1;
    The semicolon means the language will not try to treat whatever comes next as a variable name.

    The syntax is rarely used. It is more useful in C than in C++, given that C has compatible types, but even then I have never seen it used except to show that it can be done.
    Last edited by King Mir; 01-25-2010 at 11:24 AM.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. questions....so many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 08:47 AM
  2. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  3. Several Questions, main one is about protected memory
    By Tron 9000 in forum C Programming
    Replies: 3
    Last Post: 06-02-2005, 07:42 AM
  4. Trivial questions - what to do?
    By Aerie in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 12-26-2004, 08:44 AM
  5. questions questions questions.....
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-14-2001, 07:22 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21