Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C/C++ ??
#61
Nathan, I dont know how much you actually have known about C++. I mean templates are very very different from classes. Infact they are orthogonal features so you really can't compare them.

Also, I have seen all along the thread that you are boasting about studying computer science. Fine, does that make you right?

Loosecaboose, all the answers you have posted are just ways to get around the features. That doesnt really make my statements false. You can always build wrappers and make C easier and more elegant but you cant deny the fact that *all* of my statements are correct. The very fact that you have posted ways to get around them is a proof that you too agree that I am correct.

Quote:And in six months I'll be a computer engineer, so what I know is what it is.
And just FYI, Nathan and everybody. I am too doing a degree course from a very prestigious university in Software Engineering. I was avoiding posting this. Don't belittle someone just because they are not going to be 'computer engineers'.
Reply
#62
Quote:Loosecaboose, all the answers you have posted are just ways to get around the features. That doesnt really make my statements false.

I said at the beginning of my post not to take the code I gave seriously. I don't write C code that looks like hacked OO code, I was just pointing out what can be done with a little knowledge of C.

IMHO, C++ can be viewed as C with Object Orientated programming bolted onto it. Because the designers choose to make it "backward compatible" with C they added unecessary complexity to the language. One of the goals of Java was to provide a clean OO language using the C syntax, Java (or C#) is what C++ should have been.

I had an discussion once with one of the PhD students at my University who believed that OO is merely a concept, not necessarily a compiler feature. It is possible to write OO code in a non-OO language, simply by adhering to the concepts of OO (ie using getters and setters rather than accessing variables directly). Computers only natively understand procedural code, so when OO code is compiled it becomes procedural code which runs with all the benefits of the OO design, hence it is possible to adjust ones method of program to adhere to the OO concept in a procedural language.

Quote:I mean templates are very very different from classes.
Collections and generics are still a much better way of providing general implementations of a class (IMHO). C also provides ways of creating generic implementations of functions. The qsort function from the Standard library can be used to sort any arbitary data type for example, it may not be as elegant as some of the OO implementations but it is quite sufficient.

Quote:Oh, come on, talk about laaazy.
Perhaps it was a bad example, method overloading is very useful. Most often it is used in the constructors for a class to allow a class to instantiated in different ways.
esus saves.... Passes to Moses, shoots, he scores!
Reply
#63
Quote:Also, I have seen all along the thread that you are boasting about studying computer science. Fine, does that make you right?

This time yes.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#64
Well, Loose...I'll take your word for it.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#65
Quote:
TheBigBasicQ Wrote:Also, I have seen all along the thread that you are boasting about studying computer science. Fine, does that make you right?

This time yes.

Not this time. The moment you classified templates as classes made you wrong.
Reply
#66
You misunderstood me. I meant that I was right when I said that C++ is not a proper OO language.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#67
Quote:Not this time. The moment you classified templates as classes made you wrong.

Most sites I looked at refered to "templates" as "template classes" at some point or another. I can't find anything pointing to the official C++ standard, but this from the wikipedia:
Quote:In object-oriented programming, a class consists of encapsulated instance variables and subprograms. Classes describe the rules by which objects behave; those objects, described by a particular class, are known as "instances" of said class. A class specifies the data which each instance contains; as well as the methods (functions) which the object can perform; such methods are sometimes described as "behavior".

A template contains encapsulated instance variables and subprograms (methods) and it defines the way that objects that are an (indirect) instantion of it will behave. For example with the following template (I borrowed this from http://babbage.cs.qc.edu/STL_Docs/templates.htm#T3, I know its incomplete because some of the method implentations are missing):
Code:
template <class T>
class Stack {
public:
  Stack(int = 10) ;
  ~Stack() { delete [] stackPtr ; }
  int push(const T&);
  int pop(T&) ;  
  int isEmpty() const { return top == -1 ; }
  int isFull() const { return top == size - 1 ; }
private:
  int size ;  // number of elements on Stack.
  int top ;  
  T* stackPtr ;  
};

I can create a stack of ints thusley:
Code:
Stack<int> intStack;

I now have an object called intStack which is a Stack. Which class is intStack an instantion of? It can't be int, because ints are primitives, not classes. Therefore intStack must be an instantiation of the class (template) Stack, its behaviour is defined by the Stack classes methods and variables.
esus saves.... Passes to Moses, shoots, he scores!
Reply
#68
Quote:Well, Loose...I'll take your word for it.

You shouldn't...you should understand. I had a long post to you last night showing a header file containg a class I made with 5 overloaded constructers, 3 copy constructers, 2 overloaded assignment operators, and an overloaded method. The class is a container that acts like string sometimes, and sometimes like an array of native unsigned ints. The class handles memory mangement and overwrites all memory before releasing it. The thing that's nice about overloading is this...you can initialize the class with nothing (it will be setup but sized zero), with a string, with an array of any data-type that is int-aligned...you can assign or add strings with the class, and the class can return a string equal to all the data using classinstance.str(), or a substring using classinstance.str(int starting_position, int bytes)...

This class is very overloaded...which makes the class ugly...but makes code that uses the class painless to use.

Cheers
Reply
#69
If QBasic is so old why do some people still use it, if it's never going to be updated? QBasic can't make Win32 API programs such as the higher programming languages can Cry. I'm new to Qbasic and it's my first programming language, besides a lite introduction to C++, but I find it very easy, so maybe thats why it's still being used.
Reply
#70
Initiate nuclear arming of warhead.

Quote:If QBasic is so old why do some people still use it, if it's never going to be updated? QBasic can't make Win32 API programs such as the higher programming languages can . I'm new to Qbasic and it's my first programming language, besides a lite introduction to C++, but I find it very easy, so maybe thats why it's still being used

In fact, I find that the majority of programming languages have the same degree of "higherness" as Qbasic.

PS:
I think function "overloading" is not an "Object oriented" [blasphemy!] idea. It is simply a way to make programming the same thing with differing variable types easier.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)