Thread: share structures between two projects

  1. #1
    Registered User
    Join Date
    Jun 2015
    Posts
    4

    share structures between two projects

    How to share structures between two projects?

    Code:
    Solution
         Project1(static library)
             Headers
                 Input.h: struct InputData{double D2; double T1; double Ta}
             Sources
         Project2(executable)
             Headers
             Sources
         Project3 (dynamic library)
             Headers
             Sources
                 Solver.cpp: heat transfer calculation.



    In project1, the input data is obtained from the input file and save in the struct InputData.
    In project3, it is calculated the heat transfer through a pipe. For the calculation I need the input data of the struct InputData defined in Project1.
    It is correct the following:
    Code:
     //Project3, Solver.h
    #include "../Project1/Input.h"
    class solver{
    InputData sInputData; 
    double Q;
    
    void solver();
    };
    
    
     
     //Project3, Solver.cpp
    #include "Solver.h"
    solver::solver(){
    Q=sInputData.D2*(sInputData.T2-sInputData.Ta);
    }
    
    




  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Perhaps you could save the data to a file.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 11
    Last Post: 05-25-2007, 04:39 PM
  2. Creating Share
    By IfYouSaySo in forum Windows Programming
    Replies: 4
    Last Post: 12-27-2005, 12:04 PM
  3. Share with us!
    By ILoveVectors in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 08-24-2005, 05:15 PM

Tags for this Thread