CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 19

Threaded View

  1. #1
    Join Date
    Jul 2017
    Location
    Greece
    Posts
    130

    Dynamic Library: Do you need to export variables of a class?

    Lets say you have the following class.

    Code:
    #pragma once
    #include <iostream>
    #include <vector>
    
    //-_-_-_-_-_-Class Declerations-_-_-_-_-_-//
    class Renderer;
    class Brain;
    class Transform;
    //-_-_-_-_-_-Class Declerations-_-_-_-_-_-//
    
    class Sprite
    {
    //Public Members.
    public:
    
    	Transform *transform;
    
    	std::string tag;
    
    
    //Private Members.
    private:
    
    	std::vector<Brain *> m_brains;
    
    
    //Public Methods.
    public:
    
    	//Constructor.
    	__decspec(dllexport) Sprite(std::string imagePath, glm::vec2 position = glm::vec2(0.0f, 0.0f), std::string tag = "");
    
    	//Deconstructor.
    	__decspec(dllexport) ~Sprite();
    
    
    
    
    //Private Methods.
    private:
    
    	//Render Method.
    	__decspec(dllexport) void Render(Renderer *rednerer);
    
    	};
    Do i also need to export the transform and tag variables? Or __declspec only reference to methods and functions?
    The reason I'm not putting __declspec before the class name but I manually place it in each method is because i get a link warning
    for the std::string tag .I searched on google and they say that you should not export std::base_string templates because they are
    already exported. So i tried to fix that by manually choosing which method i want to export.

    Also does it make sense to export private Methods?
    Last edited by babaliaris; November 8th, 2018 at 11:59 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured