woo,been a while since my last visit,i learned vb.net anyways i was wondering if when your using classes the entire program should have classes?
woo,been a while since my last visit,i learned vb.net anyways i was wondering if when your using classes the entire program should have classes?
Yes.
It doesn't have to. I'm not sure if I get what you mean, but if I have a class called MyClass, are you asking whether every variable has to be of that type?
What I meant was, if you're going to use classes, your entire program should be object-oriented. For consistancy's sake.
holy crap,on extreme vb i need to wait atleast 3 hours for a view..
well what i mean is that in vb.net everything thats created has its own class
also are classes something I should use often in my programs
If you're familiar with Object Oriented programming, you should use it. Not that C programming is bad, but it can save you a lot of time, and more importantly, it's practices structured programming.
And yes, there are a lot of people on the C++ forum.
>> And yes, there are a lot of people on the C++ forum.
And lots of secrets .... but none here
lol 91k+ members on vb 21k+ members here i guess this forums just better
also when should i make a class public?i cant think of a situation where it wouldnt mess up my code..i know i could just use functions but still
[looselyspeaking]A public class is essentially a struct[/looselyspeaking], possibly with functions, even though structs can have functions. If you want to, why not. I prefer to use functions, cause otherwise it breaks encapsulation
I don't use private that much, but use private whenever you need to protect a special variable.... especially if you know it won't be needed very much by other functions. For everything else, use public.Originally Posted by lilhawk2892
[offtopic]twomers, do you like my new signature? [/offtopic]
I'm glad to see the trend has caught on. I always check people's posts and sigs now! It's compulsive! Shame smilies don't work with it though Better put in something to do with the thread ...Originally Posted by joeprogrammer
[ontopic]>>For everything else, use public.
I don't know, isn't the point of the private space encapsulation??[/ontopic]
Last edited by twomers; 08-03-2006 at 07:53 PM.
My current concept of basic encapsulation is that the class should contain all
data and methods it needs, and nothing else - code outside the class should
not "need" to directly access internal data/private methods. Of course, there
are circumstances when access needs to be given (perhaps it will be more
efficient), so we have the friend access mechanism. This obviously doesn't go
into inheritance, but you get the idea.
>>if you're going to use classes, your entire program should be object-oriented.
For consistancy's sake.
Well there's consistancy and there's beating a dead horse - C++ gives you the
option of using OOP, but it isn't always the best solution - some aspects of a
program may be well represented by a class, and others might be more
cumbersome - the trick is to be able to look at your program goals and at each
particular task, and decide whether you need to use a class, and that it only
learned with experience. If you want to focus on that, then try writing some
programs using just functions (C style), and rewriting using OOP. Compare the
code and look at which representation of the task is best.
No No's:
fflush (stdin); gets (); void main ();
Goodies:
Example of fgets (); The FAQ, C/C++ Reference
My Gear:
OS - Windows XP
IDE - MS Visual C++ 2008 Express Edition
ASCII stupid question, get a stupid ANSI
sorry, but I disagree quite strongly. Use whatever paradigm fits the problem you are trying to solve. Most of the best C++ programmers actually use a combination of object-oriented, generic and functional programming.Originally Posted by joeprogrammer
Some things are better suited as free functions. As an example, have a look at the STL's algorithm functions (e.g. sort(), find(), for_each(), etc). The "traditional" OO approach would've been to declare a base "container" type with sort, find and for_each methods. Instead these are generalised free functions that allow you to use any type that conforms to the interface. Which allows you to use your own container with these functions or even use a C array!
In short, use classes where appropriate.
"I saw a sign that said 'Drink Canada Dry', so I started"
-- Brendan Behan
Free Compiler: Visual C++ 2005 Express
If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?