Thread: A few beginner's questions

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User Megidolaon's Avatar
    Join Date
    Oct 2008
    Posts
    8

    Question A few beginner's questions

    I hail from C# and C++ is confusing me a lot.

    1) I just got an error for putting the visibility identifier before the name of a method (at least I think that was the reason), so it's absolutely mandatory I use private: or public: and then put the methods and attributes after these declarations?
    And private is standard, so I don't need to write it or?

    2) I got an error for defining a method inside the class it belongs to (again, I think so), WTF?
    How can you achieve data encapsulation when half the code of a class isn't part of it but defined globally?
    In all the examples I've seen so far, it was done this way, is that mandatory or just optional?
    And if it's mandatory, how do I write libraries and encapsulate classes in them, where am I supposed to define the methods, so that I can later just call them without any extra code?

    3) Is there any kind of general exception I can catch, that at least tells me some vague info about what happened?
    I only found specific exceptions and adding the throw(...) statement to add in a function's name, but this won't tell me jack about what happened.

    4) The constructor of a class is called without using the new statement?
    What do I use the new statement for? Only for arrays?
    And that means just declaring a variable of a class (and structure/Union,too?) will allocate the necessary memory?

    5) How do I convert from numbers/Boolean into strings and back, is there anything resembling Parse/TryParse functions from C#?
    From what I've read, I can only think of outputting a number/bool into a stringstream and then inputting that back into a string. For the other way around I can only think inputting the string into the number/bool from a stringstream and then maybe using a nested try-catch block to check if it worked.

    Thanks in advance.
    Last edited by Megidolaon; 10-21-2008 at 05:10 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner's Questions
    By bjl in forum C++ Programming
    Replies: 4
    Last Post: 01-31-2008, 06:56 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, 09: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