D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] C++ Questions?

 

At Tue 17 Mar 2009 20:42:13 UTC, Sam Grabham <sam@xxxxxxxxxxxxxxxxx> wrote:

> I have started reading a 600 page book on C++ , but i haven't found   
> answers to the following:
>
> In C++ how should you use and include resource file (.rc) for multi   
> lang support for a GUI support?

.rc files are Windows-specific. If you include copies of the same  
resources in different languages then Windows will choose the one  
appropriate for the current system language when the resource is  
loaded into the app.

On linux, the mechanism for resources and multiple language support  
depends on your GUI toolkit.

> In the books i have been reading the examples show all classes and   
> functions all on one .cpp file.
>
> In VB you would use lots of .bas files for all your extra common   
> code and recycle the code in other projects.
>
> How should you structure code for easier coding? would you use   
> another . cpp file and prototye the functions in the main.cpp file.

Divide code into separate files based on the responsibilities  
represented. A reasonable guideline to start with is one class => one  
.h/.cpp pair.

Put all your declarations in .h files rather than prototyping them in  
your .cpp files. Then when you need to use the class or functions in  
another .cpp file you can just #include the .h file.

> How would you create GUI user controls like grids that get reused   
> again and again (ocx ?) .

You can write an OCX in C++ too. It's not something I'd recommend for  
beginners though, as it's quite complex.

> When would you create a .h file?

When you have declarations of classes or functions that need to be  
used from more than one .cpp file.

> are the compiled object files the same as dll's?

No. Each .cpp file compiles into a single object file (.obj). DLLs are  
linked from compiled object files the same way as a complete EXE. DLLs  
may "export" functions which can then be used by other DLLs or EXEs  
which "import" the functions from that DLL.

> and can you ref them into you compiled exe, In Lunix or windows?

That's the whole point of DLLs --- you use them from your EXEs. You  
use DLLs for three purposes:

* reuse the same code in multiple apps,
* as plugins to enable extra functionality after the app is built  
(e.g. photoshop plugins)
* to separate discrete chunks of an application that can be changed  
and rebuilt separately.

Linux has "Shared Object" .so files instead of DLLs. The process is  
similar to DLLs --- compile some object files (.o on linux) and link  
to a .so. The .so can then be loaded into an executable program in  
order for the program to use the functions from the .so file.

Anthony
-- 
Anthony Williams
Author of C++ Concurrency in Action | http://www.manning.com/williams
just::thread C++0x thread library   | http://www.stdthread.co.uk
Custom Software Development         | http://www.justsoftwaresolutions.co.uk
Just Software Solutions Ltd, Registered in England, Company Number 5478976.
Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK



-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html