Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ Constructor inheritance not working correctly
    primarykey
    data
    text
    <p>This is the dependent class header</p> <pre><code>#ifndef TransHeader #define TransHeader #include &lt;string&gt; #include "CipherHeader.h" using namespace std; class Trans : public Cipher { public: Trans(string filenameIn); const static int MAXSIZE = 10000; void createArray(); void transEncrypt(); void transDecrypt(); private: //string Key; //string inputData; char dataArray[MAXSIZE][MAXSIZE]; }; #endif </code></pre> <p>This is the inherited header</p> <pre><code>#ifndef CipherHeader #define CipherHeader #include &lt;string&gt; using namespace std; class Cipher { public: const static int MAXSIZE = 10000; Cipher(string filenameIn); void getKey(); void flagHandle(string); string Key; string inputData; string filename; string flags; string readFile(); void writeFile(); private: }; #endif </code></pre> <p>The problem is after I call the base constructor</p> <pre><code>Trans::Trans(string filenameIn) : Cipher(filenameIn) {} </code></pre> <p>I cannot call the constructor in a normal file like so:</p> <pre><code>#include "Trans.cpp" int main() { string a = "asdf"; Trans *c = new Trans(a); } </code></pre> <p>This results in this error:</p> <pre><code>g++ test.cpp -o test.out /tmp/ccbuqMYr.o: In function `Trans::Trans(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;)': test.cpp:(.text+0x35): undefined reference to `Cipher::Cipher(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;)' /tmp/ccbuqMYr.o: In function `Trans::Trans(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;)': test.cpp:(.text+0xa5): undefined reference to `Cipher::Cipher(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;)' collect2: ld returned 1 exit status </code></pre> <p>replacing Trans with Cipher works just fine and runs. I have tried everything I know, googled excessively, and cannot figure out this error. Other design problems, ect will be dealt with later, this is my main problem. Please help.</p> <p>EDIT:: definition of Cipher</p> <pre><code>Cipher::Cipher(string filenameIn) { filename = filenameIn; readFile(); getKey(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload