Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

yg17

macrumors Pentium
Original poster
Aug 1, 2004
15,029
3,004
St. Louis, MO
I'm a computer science major, and for our assingments, we have to use visual studio.net and c++ to write a program with a GUI. Unfortunatley, I'm forced to use windows for this work. I'd like to teach myself how to write programs with GUIs using C++ anyways, since right now on a Mac or *nix system I can only do boring terminal programs. I looked around x-code, and it seems to only work with GUIs and Objective C and Java. I'd rather get used to XCode with what I already know, so is there a way to use C++ to write programs with GUIs? Thanks
 
GUIs are rather OS dependent. Well really they are framework (library) dependent. When working in Windows you'll be using the MFC or .Net Frameworks, and on OS X you'll be using the Carbon or Cocoa frameworks. These frameworks are mutually exclusive.

Now.. if you really wanted to write software that would compile on window/mac/X11(unix) then check out qt by trolltech. Its a nice windowing framework that has implementations on all major platforms.
 
csubear said:
GUIs are rather OS dependent. Well really they are framework (library) dependent. When working in Windows you'll be using the MFC or .Net Frameworks, and on OS X you'll be using the Carbon or Cocoa frameworks. These frameworks are mutually exclusive.

Now.. if you really wanted to write software that would compile on window/mac/X11(unix) then check out qt by trolltech. Its a nice windowing framework that has implementations on all major platforms.

Im not looking for cross platform compatibility. Just something like VS.net/MFC for Mac where I make a GUI interface then write c++ code to interact with it
 
Use XCode + Interfacebuilder, it kicks major ass. Objective-C is a great language too :-D
 
Objective C's dynamic runtime makes it particularly useful for user interface work. Rather than defining integer constants for actions, coding in callbacks, or (ugh) letting a graphical editor write C++ code for you, you simply draw lines in interface builder, and let the runtime find the right methods and instance variables when the program is executing. Forget about the old "subclassing the dialog" approach!

If you have a reasonably good understanding of C and object oriented principles, it is really easy to learn Objective C. If you can get a book like Aaron Hillegass' "Cocoa Programming for Mac OS X", you'll learn all you need to get started in one evening.

You'll wonder why they teach C++ GUI programming at all. (The conspiracy theorist in me presumes your school gets some nice kickbacks from Redmond, though.)
 
You can use c++ with obj-C. I have done this before. I think you need to use a complier flag to get this to work. The idea is you create your c++ backend, and then create a controller class that interfaces to the GUI for each gui framework you want to use.
 
dweebert said:
You'll wonder why they teach C++ GUI programming at all. (The conspiracy theorist in me presumes your school gets some nice kickbacks from Redmond, though.)

Considering I can probably count the number of Macs on campus outside of the dorms on one hand, I think you may be right.

Thanks everyone, Ill look into it
 
Qt from Trolltech provides you with a library for GUI programming, and has some tools for designing widgets. It also has the benefit of being a cross platform library, so your code should work on Macs/linux/Windows. Easy to lern, easy to use, I recommend it strongly...
 
kingjr3 said:
Obj-C isn't much of a stretch from C++. A couple different syntatical differences, but the ideas are the same. I recommend you give it a try and then you can leverage all the Cocoa Frameworks/APIs.

Altough learning Obj-C isn't difficult if you have previous knowledge of C++ or Java, I would not say there are only syntactical differences. The syntactical difference is just something to get used to.

However, Obj-C's dynamic typing, as opposed to C++ and Java's static typing, requires a completely different way of thinking about your OO designs. Only when you're aware of this, you will be able to use Obj-C's advantages to their full extent.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.