Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Common C Questions : TURBO C/C++ - Getting Started Answers to Common Questions

Questions:What potential problems can arise from typecasting a Base Class pointer into a derived class pointer so that the derived class's member functions can be called?
Answers: Syntactically this is allowable. There is always a possibility of a base pointer actually pointing to a base class. If this is typecast to a derived type, the method being called may not exist in the base class. Therefore, you would be grabbing the address of a function that does not exist.

TURBO C/C++: Installer and Installation
TURBO C/C++: Integrated EnvironmentVariables Pointer Array And Files
Arrays Linked List Sorting Wild Pointer

Questions:What's the difference between the keywords STRUCT and CLASS?
Answers:The members of a STRUCT are PUBLIC by default, while in CLASS,they default to PRIVATE. They are otherwise functionally equivalent.

[next]Questions:I have declared a derived class from a base class, but I can't access any of the base class members with the derived class function.
Answers:Derived classes DO NOT get access to private members of a base class.In order to access members of a base class, the base class members must be declared as either public or protected. If they are public, then any portion of the program can access them. If they are protected, they are accessible by the class members, friends, and any derived classes.

Questions:How can I use the Paradox Engine with C++?,
Answers:Because the Paradox Engine functions are all compiled as C functions you will have to assure that the names of the functions do not get "mangled" by the C++ compiler. To do this you need to prototype the Engine functions as extern "C". In the pxengine.h header file insert the following code at the lines indicated.

/* inserted at line # 268 */
#ifdef __cplusplus
extern "C" {
/* inserted at line # 732, just before the final #endif */
#ifdef __cplusplus

Questions:I have a class that is derived from three base classes. Can I insure that one base class constructor will be called before all other constructors?
Answers:If you declare the base class as a virtual base class, its constructor will be called before any non-virtual base class constructors. Otherwise the constructors are called in left-to-right order on the declaration line for the class.

Questions:Are the standard library I/O functions still available for use with the C++ iostreams library?
Answers:Yes, using
#include <stdio.h>
functions such as printf() and scanf() will continue to be available.

Questions:When debugging my program in Turbo Debugger, I notice that none of my inline functions are expanded inline. Instead, they are all done as function calls.
Answers:Whenever you compile your program with debugging information included,no functions are expanded inline. To verify that your inline functions are indeed expanding inline, compile a module with the -S flag of the command-line compiler, then examine the .asm file that is generated.


This post first appeared on IngenuityDias, please read the originial post: here

Share the post

Common C Questions : TURBO C/C++ - Getting Started Answers to Common Questions


Subscribe to Ingenuitydias

Get updates delivered right to your inbox!

Thank you for your subscription