what's the difference between c and c++?
difference between c++ on windows and c++ on linux system?
Printable View
what's the difference between c and c++?
difference between c++ on windows and c++ on linux system?
I'll start this off:
In C, anyvariable++ increases it's value by one after whatever you're doing to it, so C++ in ment to mean the next version of C, which it is :)
After that there's C# (see-sharp), and then M$'s .Net iirc :(
The same C++ code will have to be compiled differently for different OSs IIRC, as it's a compiled language, not interpreted each time it's run regardless of the OS :)
C++ is more powerful because it has a much larger Standard Library
It's also Object-Oriented. From what I understand, think of a pc card game. If you make the object/class 'pile-o-cards', you can then use instances of it in any card game, instead of tracking all the cards. In Solitare you redefine them to accept Aces, but in FreeCell you don't. They still act like a 'pile-o-cards', but you can taylor them to each game's rules, so it's faster too.
Try the links in here, oh and here
quick and dirty.....
c was developed in the early '70's to be a powerful, portable languge. a lot of operating systems are written primarly in c....windows, unix.....
c++ is a superset of of c, and adds object oriented features to c. c++ is arguably the most used language out there.
i read in the july issue of wired that there's talk of a virtual machine for c++, if anything ever comes of that then you won't need to recompile the code to run on different operating systems, but until then binaries from unix won't run on windows, and vice versa.
You need to know C before you start C++ because there is alot of C in C++ C++ is a more complex type of a format it works better and it is better to wright in C++ so youll have more option in coding but both lang is hard to learn and to understand but im sure youll get it with the proper tools and help
I thought .Net was a basic style of programming to follow up VB 6Quote:
>>difference between c++ on windows and c++ on linux system?
Differnt compilers which have different header files for functions. Basic functioning and programming on a Win or *nix system will be the same though.
>>You need to know C before you start C++...
Not neccessarily. Lot of guys I know started with c++ and are doing pretty well.
But if you decide to learn C++ first some basic knowledge of C would also do well since C++ can accomodate C in it. Like Jabberwocky said "C++ is a superset of C"
I agree, you don't need to know C before C++. I learned C++ without any previous knowlege of C, and do quite fine - infact my school teaches you C++ and never any C. I can't say I really know how to progam in C, but I can understand decently commented C code without problems.Quote:
Originally posted here by ihsir
>>You need to know C before you start C++...
Not neccessarily. Lot of guys I know started with c++ and are doing pretty well.
But if you decide to learn C++ first some basic knowledge of C would also do well since C++ can accomodate C in it. Like Jabberwocky said "C++ is a superset of C"
Ok so you know the history of C and C++ and that C is a subset of C++. C is a Structured programming language. While C++ is an Object-Oriented Language. You can do a lot of stuff in C++ as compared to C.
Structured programming language i.e. C uses modules and functions that perform specific tasks like printing text, performing calculations etc. Functions make it easy for the programmer to divide his programs into a no. of tasks, thus making it easier to program. It uses the concept of divide and conquer. Functions can be either provided by the manufacturer of the compiler (pre-defined functions) or could be made by you (user-defined functions).
You can say that C is a go to less programming as it seldom uses go to statements. Most of the operations in C are done using the following constructs: Sequence, Selection and Repetition. Sequence is a step by step execution of program statements, Selection is the use of conditional execution like the well-known if statement (or functions in C) and Repetition is the repetition of a group of statements like in While statement and For statements.
Object-oriented programming languages (like C++) use the concept of re-usability of software or program components. You don’t have to re-invent the wheel. It uses the concept of information hiding, inheritance and polymorphism.
Like in C, C++ mostly uses pre-defined functions. It uses classes to hold data and functions. Data are states of the classes and functions are behaviors of the classes. Functions present in a class manipulate its data. Objects are instances (or implementations) of classes.
Classes communicate with one another so they provide that data to other classes that is necessary and hide the rest of the info. It is much like driving a car without knowing its internal working.
Inheritance allows one class to inherit some properties like data and functions from other classes. The class that inherits is called sub-class and its parent class (from which other classes inherit) is called the super class.
Polymorphism is one interface but many implementations. You can do a lot of stuff by giving one command. I think that’s all you need to know about polymorphism at this moment.
For programming in Windows you will have to use Visual C++. However you will need to learn C++ to use VC++. In MS-DOS and LINUX based programming the C++ program calls the operating system to get the user input and in Windows based programming the OS i.e. Windows issues messages whenever a user inputs something e.g. mouse clicks and button press etc for all of these special messages are sent to the C++ program. The messages sent by Windows are mapped in the C++ programs to perform a specific task using a the data received from the OS.
I hope that this helps. If you have any doubts then don’t hesitate to ask.
For more info about C language visit the site:
www.cprogramming.edu
If u want to see online journals on C/C++ then visit:
www.cuj.com
www.ddj.com
This might be somewhat off topic but I thought I'd say some anyway. I see there's something of a confusion around C# and .NET and I thought I'd clear it up.
I've been programming C# for the last two years and that's longer than the language have been publicly available. I've written a number of articles on C# in European and American magazines and I run one of the largest C# sites on the internet. Let me share my views on C# and .NET
C# is *NOT* the next dialect of C. At least no more than Java is. The syntax is similar but the inner workings are wholly different. C# is created for use with the .NET class library, executing withing the .NET runtime. Much like Java does with its JVM or VB does with vbrun.dll.
There is however a desire by some people (at Microsoft amongst others) that C# is viewed as the next version of C. The thing is that C# isn't a stand alone language. It can't be used with out the .NET Common Type System, the Common Language Runtime, both part of the .NET Common Language Specification.
There are currently ports beeing developed for linux (go-mono.com) and freeBSD (a cooperation between MS and Corel) of both the .NET runtime and C#.
Concerning .NET it's more than guidelines. .NET is a runtime, a set of classes and a way to write programs using .NET enabled languages (languages that follow the .NET specification).
Visual Studio .NET and the .NET SDK ships with four .NET enabled languages C#, VB.NET, JScript.NET (which now, low and behold is an actual programming languge) and C++ with managed extentions (which, if anything should be regarded as the next version of C++).
There's also a nifty little language called J# that from a strategic point of view looks like a .NET enabled J++ with all the politics that came with the latter.
Anyway. I gotta go. Hope I could help some. Any questions -> PM me.
Cheers,
Thanks for clearing that up - I never considered C# the predicessor to C/C++Quote:
Mankan, having been sheltered from .NET thus far, i have a few questions related to the runtime architecture with regard to pre-existing COM stds, specifically:
- do .NET classes expose public interfaces derived from IUnknown?
- automation, and dual interfacing capabilities
- hosting options; COM+ or other surrogates
- registry or COM+ application registry dependence (guid, clsid, appid, etc.)
i guess the simple answer if it all fits together nicely is that it's all supported; but if there are keynote differences that you can think of without digging through whitepapers - i'd really enjoy getting some feedback on it.
tia.
I will give an example of the difference between c and c++
/* C Code */
struct stack
{
An example
/* C code*/
struct stack
{
int elt[100];
int top ;
}s;
void push(int x)
{
/* code to push*/
}
int pop()
{
/* code to pop*/
}
void main()
{
int i;
s.push(100);
i = s.pop();
}
// c++ code
class stack
{
private :
int elt[100],top;
public:
void push();
int pop();
} s;
main()
{
int i;
s.push(100);
i = s.pop();
}
U can clearly see that in C++ , not only the properties(say variables), but also the methods(functions) to act on those variables are part of the datatype.
Quote:
Originally posted here by droby10
Mankan, having been sheltered from .NET thus far, i have a few questions related to the runtime architecture with regard to pre-existing COM stds, specifically:
- do .NET classes expose public interfaces derived from IUnknown?
- automation, and dual interfacing capabilities
- hosting options; COM+ or other surrogates
- registry or COM+ application registry dependence (guid, clsid, appid, etc.)
i guess the simple answer if it all fits together nicely is that it's all supported; but if there are keynote differences that you can think of without digging through whitepapers - i'd really enjoy getting some feedback on it.
tia.
Introduced with the .NET architecture is the concept of assemblies. Each compilation results in an Assembly, shared or private but I will get to this in a moment. The Assembly is numbered a.b.x.y where x and y are regarded as smaller differences and the assembly will be backwards compatible. a and b are used for larger changes. The code might break so the actual dll is never replaced but a side by side execution takes place.
An assembly is totally selfcontained with metadata code and everything it needs. It can, but doesn't have to span multiple physical files. Think of it as a logical dll. There are some benefits that comes with this. - First, there is no more DLL-hell. No registration process takes place and two assemblys with the same name can exist and execute side by side (as long as their respective a and b numbers in the version number is different). Oh, and another feature is drag n' drop (or xcopy if you're into DOS) deployment.
No .NET classes expose the traditional COM interfaces because there is no need to do so. There is however possible to wrap a .NET class in a COM-wrapper give it a typelib a public key and what not and then register. The .NET class will then operate and behave as any normal COM object. The performance overhead for doing this is quite severe though.
What have been said so far is espesially true for private assemblies which are stored at whatever destination that was chosen at the installation. The DLL is the Assembly remember?
There are as earlier mentioned something called shared asseblies as well. These coud be morethought of as shared libraries in Unix. They are self contained but stored in the GAC, the Global Assembly Cache where other .NET programs all can interact with it.
The security thinking behind assemblies is also really nice since it is possible to set permissions on each assembly.
Assemblys can also be downloaded and installed on demand so the initial installation can be smaller and features that are never used might never download.
Maybe I should edit this some and put it as a tutorial instead? It got kinda long. Anyway, I hope you get the big picture. The thought of assemblies is really nifty and certainly a more enjoyable way to work than the old COM objects.
Cheers,
ok.. thanks for everyones excellent replies :D