+ Post New Thread
Results 1 to 3 of 3
  1. #1
    Junior Member level 1
    Points: 263, Level: 3

    Join Date
    Dec 2017
    Posts
    16
    Helped
    0 / 0
    Points
    263
    Level
    3

    How to specify object name when using .h and .CPP file

    I have LCD class and a object lcd as follows.

    Code:
    class LCD{
    public:
    ...
    ...
    }lcd;
    How to specify lcd object with two files lcd.h and lcd.cpp

    •   AltAdvertisment

        
       

  2. #2
    Junior Member level 1
    Points: 76, Level: 1
    AskSensors's Avatar
    Join Date
    Oct 2018
    Location
    Paris
    Posts
    15
    Helped
    0 / 0
    Points
    76
    Level
    1

    Re: How to specify object name when using .h and .CPP file

    Hello,
    I don't see what you mean.
    Could you specify :
    - The IDE you are using?
    - Where are you putting the main code ? is in a main file?



    •   AltAdvertisment

        
       

  3. #3
    Junior Member level 1
    Points: 263, Level: 3

    Join Date
    Dec 2017
    Posts
    16
    Helped
    0 / 0
    Points
    263
    Level
    3

    Re: How to specify object name when using .h and .CPP file

    Quote Originally Posted by AskSensors View Post
    Hello,
    I don't see what you mean.
    Could you specify :
    - The IDE you are using?
    - Where are you putting the main code ? is in a main file?
    I am using DevC++.
    I need to write
    lcd.h
    Code:
    class LCD{
    void display(char);
    };
    lcd.cpp
    Code:
    void LCD :: display(char c){
    //my code
    }
    Then in main.cpp
    Code:
    #include <iostream>
    using namespace std;
    
    int main(){
    LCD lcd; // Is any way to not specify hear but anywhere else in lcd.h or lcd.cpp
    lcd.display(A);
    return 0;
    }



--[[ ]]--