start a class in BCB

Posted on 2005-05-04
Medium Priority
Last Modified: 2013-11-17

   How do I start a class in BCB ? new a "Unit" ? or something else ? many thanks !
Question by:meow00
LVL 12

Assisted Solution

andrewjb earned 60 total points
ID: 13924981
Errr... put it where you want? A new unit is probably kind of neat and tidy. Rather depends what you want to do... You could create classes in your main form's unit if you want, it'd just get rather monolothic and messy. BCB is pretty much the same as any other compiler in this respect. What's the problem?
LVL 16

Accepted Solution

George Tokas earned 780 total points
ID: 13925977
Addition at andrewjb post:
The answer is anywere as andrewjb posted...
If you want that piece of code (the class ) to be reusable then it will be better to have its own space...
This will create a unitx.cpp and unitx.h...
Rename it to something to remember that it is your class... I.e. "MyClass.cpp" & "MyClass.h"...
At the header file declare the class:
#ifndef MyClassH
#define MyClassH
class MyClass
//your private members
//the protected members here
  ~MyClass();//destructor. Those MUST be public


Those for the header. As for .cpp
#include MyClass.h

//Constructor code here if needed.

//Destructor code here if needed.

Thats all for the class to reuse it anywere you like at any project...
As for expanding the class its pretty straightforward...
Declare a function at .h and write the code at .cpp...
The same way you are working at main form on any project at BCB...
Remember that and by default when you are working on BCB and starting a new application you are working in a class the Form1 class...


Assisted Solution

balder earned 60 total points
ID: 13926148
There is no class wizard in BCB, you just declare and define your classes directly in new or existing files as explained above.

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month15 days, 10 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question