this is my displacement.h

 #ifndef DISPLACEMENT_H
 #define DISPLACEMENT_H

  class displacement 
    {
        public:
            displacement(double, double, double);
            double getvalue();
        private:
            double s,t,a,v ;
    }

    #endif

this is my displacement.cpp

  #include "displacement.h"

;using namespace std;

displacement::displacement(double t1,double a1,double v1)
{
    t=t1;
    a=a1;
    v=v1;
    s = v * t -(0.5) * a * t * t;

}
double displacement::getvalue()
{
    return s;
}

this is my acceleration.h

  #ifndef ACCELERATION_H
    #define ACCELERATION_H




    class acceleration 
    {
        public:
            acceleration(double, double, double);
            double getvalue();
        private:
            double u,t,a,v ;
    }

    #endif

this is my acceleration.cpp

   #include "acceleration.h"

    ;using namespace std;



    acceleration::acceleration(double t1,double u1,double v1)
    {
        t=t1;
        u=u1;
        v=v1;
        a = (v-u)/t;

    }
    double acceleration::getvalue()
    {
        return a;
    }

this is my Form1.h

 #pragma once

    #include "acceleration.h"
    #include "displacement.h"

    ;namespace assignment {

        using namespace System;
        using namespace System::ComponentModel;
        using namespace System::Collections;
        using namespace System::Windows::Forms;
        using namespace System::Data;
        using namespace System::Drawing;

        /// <summary>
        /// Summary for Form1
        /// </summary>
        public ref class Form1 : public System::Windows::Forms::Form
        {
        public:
            Form1(void)
            {
                InitializeComponent();
                //
                //TODO: Add the constructor code here
                //
            }

        protected:
            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            ~Form1()
            {
                if (components)
                {
                    delete components;
                }
            }
        private: System::Windows::Forms::Label^  label1;
        private: System::Windows::Forms::Label^  label2;
        private: System::Windows::Forms::Label^  label3;
        private: System::Windows::Forms::Label^  label4;
        private: System::Windows::Forms::Label^  label5;
        private: System::Windows::Forms::TextBox^  textBox1;
        private: System::Windows::Forms::TextBox^  textBox2;
        private: System::Windows::Forms::TextBox^  textBox3;
        private: System::Windows::Forms::TextBox^  textBox4;

        private: System::Windows::Forms::ComboBox^  comboBox1;
        private: System::Windows::Forms::Button^  button1;
        private: System::Windows::Forms::TextBox^  textBox6;
        private: System::Windows::Forms::Label^  label6;
        protected: 

        private:
            /// <summary>
            /// Required designer variable.
            /// </summary>
            System::ComponentModel::Container ^components;

    #pragma region Windows Form Designer generated code
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            void InitializeComponent(void)
            {
                this->label1 = (gcnew System::Windows::Forms::Label());
                this->label2 = (gcnew System::Windows::Forms::Label());
                this->label3 = (gcnew System::Windows::Forms::Label());
                this->label4 = (gcnew System::Windows::Forms::Label());
                this->label5 = (gcnew System::Windows::Forms::Label());
                this->textBox1 = (gcnew System::Windows::Forms::TextBox());
                this->textBox2 = (gcnew System::Windows::Forms::TextBox());
                this->textBox3 = (gcnew System::Windows::Forms::TextBox());
                this->textBox4 = (gcnew System::Windows::Forms::TextBox());
                this->comboBox1 = (gcnew System::Windows::Forms::ComboBox());
                this->button1 = (gcnew System::Windows::Forms::Button());
                this->textBox6 = (gcnew System::Windows::Forms::TextBox());
                this->label6 = (gcnew System::Windows::Forms::Label());
                this->SuspendLayout();
                // 
                // label1
                // 
                this->label1->AutoSize = true;
                this->label1->Location = System::Drawing::Point(20, 36);
                this->label1->Name = L"label1";
                this->label1->Size = System::Drawing::Size(13, 13);
                this->label1->TabIndex = 0;
                this->label1->Text = L"a";
                // 
                // label2
                // 
                this->label2->AutoSize = true;
                this->label2->Location = System::Drawing::Point(23, 64);
                this->label2->Name = L"label2";
                this->label2->Size = System::Drawing::Size(10, 13);
                this->label2->TabIndex = 1;
                this->label2->Text = L"t";
                // 
                // label3
                // 
                this->label3->AutoSize = true;
                this->label3->Location = System::Drawing::Point(20, 92);
                this->label3->Name = L"label3";
                this->label3->Size = System::Drawing::Size(13, 13);
                this->label3->TabIndex = 2;
                this->label3->Text = L"u";
                // 
                // label4
                // 
                this->label4->AutoSize = true;
                this->label4->Location = System::Drawing::Point(21, 121);
                this->label4->Name = L"label4";
                this->label4->Size = System::Drawing::Size(13, 13);
                this->label4->TabIndex = 3;
                this->label4->Text = L"v";
                // 
                // label5
                // 
                this->label5->AutoSize = true;
                this->label5->Location = System::Drawing::Point(154, 97);
                this->label5->Name = L"label5";
                this->label5->Size = System::Drawing::Size(12, 13);
                this->label5->TabIndex = 4;
                this->label5->Text = L"s";
                // 
                // textBox1
                // 
                this->textBox1->Location = System::Drawing::Point(39, 33);
                this->textBox1->Name = L"textBox1";
                this->textBox1->Size = System::Drawing::Size(100, 20);
                this->textBox1->TabIndex = 5;
                // 
                // textBox2
                // 
                this->textBox2->Location = System::Drawing::Point(40, 57);
                this->textBox2->Name = L"textBox2";
                this->textBox2->Size = System::Drawing::Size(100, 20);
                this->textBox2->TabIndex = 6;
                // 
                // textBox3
                // 
                this->textBox3->Location = System::Drawing::Point(39, 90);
                this->textBox3->Name = L"textBox3";
                this->textBox3->Size = System::Drawing::Size(100, 20);
                this->textBox3->TabIndex = 7;
                // 
                // textBox4
                // 
                this->textBox4->Location = System::Drawing::Point(40, 118);
                this->textBox4->Name = L"textBox4";
                this->textBox4->Size = System::Drawing::Size(100, 20);
                this->textBox4->TabIndex = 8;
                // 
                // comboBox1
                // 
                this->comboBox1->FormattingEnabled = true;
                this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^  >(2) {L"meter", L"kilometer"});
                this->comboBox1->Location = System::Drawing::Point(40, 176);
                this->comboBox1->Name = L"comboBox1";
                this->comboBox1->Size = System::Drawing::Size(121, 21);
                this->comboBox1->TabIndex = 10;
                // 
                // button1
                // 
                this->button1->Location = System::Drawing::Point(86, 215);
                this->button1->Name = L"button1";
                this->button1->Size = System::Drawing::Size(75, 23);
                this->button1->TabIndex = 11;
                this->button1->Text = L"Calculate";
                this->button1->UseVisualStyleBackColor = true;
                this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
                // 
                // textBox6
                // 
                this->textBox6->Location = System::Drawing::Point(172, 92);
                this->textBox6->Name = L"textBox6";
                this->textBox6->Size = System::Drawing::Size(100, 20);
                this->textBox6->TabIndex = 12;
                // 
                // label6
                // 
                this->label6->AutoSize = true;
                this->label6->Location = System::Drawing::Point(218, 153);
                this->label6->Name = L"label6";
                this->label6->Size = System::Drawing::Size(0, 13);
                this->label6->TabIndex = 13;
                // 
                // Form1
                // 
                this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
                this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
                this->ClientSize = System::Drawing::Size(284, 264);
                this->Controls->Add(this->label6);
                this->Controls->Add(this->textBox6);
                this->Controls->Add(this->button1);
                this->Controls->Add(this->comboBox1);
                this->Controls->Add(this->textBox4);
                this->Controls->Add(this->textBox3);
                this->Controls->Add(this->textBox2);
                this->Controls->Add(this->textBox1);
                this->Controls->Add(this->label5);
                this->Controls->Add(this->label4);
                this->Controls->Add(this->label3);
                this->Controls->Add(this->label2);
                this->Controls->Add(this->label1);
                this->Name = L"Form1";
                this->Text = L"Form1";
                this->ResumeLayout(false);
                this->PerformLayout();

            }
    #pragma endregion

    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
             {
                double a,t1,u1,v1,s,a1,s1,s2,s3,s4 ;

                if ( textBox3->Text != "" && textBox2->Text != "" && textBox4->Text != "" && textBox1->Text == ""  )
                {

                    t1= System::Convert::ToDouble(textBox2->Text);
                    u1= System::Convert::ToDouble(textBox3->Text);
                    v1= System::Convert::ToDouble(textBox4->Text);
                    acceleration accelerationobject(t1,u1,v1);
                    textBox6->Text = "a1 = " + System::Convert::ToString(accelerationobject.getvalue());

                }
                else if (  textBox1->Text != "" && textBox2->Text != "" && textBox4->Text != "" && textBox3->Text == "" )
                {
                    a1= System::Convert::ToDouble(textBox1->Text);
                    t1= System::Convert::ToDouble(textBox2->Text);
                    v1= System::Convert::ToDouble(textBox4->Text);
                    displacement displacementobject(t1,a1,v1);
                    textBox6->Text = "   s2 = " + System::Convert::ToString(displacementobject.getvalue());
                }


             }
    };



    }

I am having problem in including two header file in "form1.h". The compiler successfull build solution when i include only one of the header file. I get error C2236 which is unexpected class error when i compile the code above. Please help me to solve this problem as i am new to c++. Thank you.

you need a semicolon ; at the end of the class declaration in the header files. Also, in the *.cpp files, remove the semicolon before using namespace std statement

class foo
{

   // stuff here

}; // <<<<<< 

Ya...exactly work!! My mistake...thanks a lot! :)

whenever you make any headers, you should link them together. Like:

#include "header1.h" 

inside your second header. Then do

#include "header2.h"

inside your third header. Then do

#include "header3.h"

inside your main_program.cpp

Does that make sense? Sometimes my explanations do not make sense, which is why I am asking if it makes sense.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.