Solved

c++ beginner (Bbuilder)

Posted on 2000-04-05
2
387 Views
Last Modified: 2012-05-04
Hi, I'm new in c++ Builder and I have following problem
In Delphi I declared public procedures & functions in public part of declarations and then later in code I wrote whole stuff so I'm able to acces these proc & functions form another forms

In builder I found .h files and i added function declaration in public part and then a wrote function in .cpp file but when i try to use my function I'm getting Linker error

example

part of my test_.h file
--------------------------------------

class TForm1 : public TForm
{
__published:      // IDE-managed Components
        TButton *Button1;
        void __fastcall Button1Click(TObject *Sender);
private:      // User declarations
public:            // User declarations
      void  vca (int ulaz);//<------ my declaration
        __fastcall TForm1(TComponent* Owner);
};


and implemenation in test_.cpp
-----------------------------------

void vca(int ulaz) {
//do somthing here (later)
}


& I try to call my function on button click
------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
Form1->vca(5);
}


When i try to compile program result is:
---------------------------------------------------------------
[Linker Error] Unresolved external 'TForm1::vca(int)' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER4\PROJECTS\TEST_.OBJ.

Or when i try to implement my function as

TForm1::vca(int ulaz)  {
}

error is
[C++ Error] test_.cpp(16): E2316 'TForm1::vca(int)' is not a member of 'TForm1'.


I'm begginer so plese try to give as much detaile's as possible.
Regards Vedran

0
Comment
Question by:xtvca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
DrDelphi earned 20 total points
ID: 2687650
Header://---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published:      // IDE-managed Components
    TButton *Button1;
    void __fastcall Button1Click(TObject *Sender);
private:      // User declarations
public:            // User declarations
     void __fastcall DoSomething();
     __fastcall TForm1(TComponent* Owner);

};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

CPP file:

//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DoSomething()
{
  ShowMessage("Dave was here");
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  DoSomething();
}
//---------------------------------------------------------------------------





You'll note that I use __fastcall and that I reference TForm1 when implemtning the function:

void __fastcall TForm1::DoSomething()


Good luck!!



0
 

Author Comment

by:xtvca
ID: 2687866
This was great.
Thanks

You know I posted same question on c++ section but the answer was not at all good as this

Wll look like the Delphi folks rules in quality/support/speed matter.

RegarDs,
Vedran

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

623 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