start a class in BCB

Posted on 2005-05-04
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

    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

    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...

    LVL 3

    Assisted Solution

    There is no class wizard in BCB, you just declare and define your classes directly in new or existing files as explained above.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Suggested Solutions

    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…
    Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project ( automates most of the tasks discussed in this article. You can even fin…
    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 keystrokes in Netbeans IDE 8.0 for Windows.

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now