user10634: I have made two libraries and one test program.I have made my custom uart library.first i have included all functions for printing in single uart library file.but then i have made print library for printing functions only.my files are listed below.i have not posted my code directly so it can be read separately.
uart.h
uart.cpp
print.h
print.cpp

Test.cpp

#include <avr/io.h>                                                          
#include "uart.h"

int main(){
    uart.start(9600);
    uart.print("Test");
}

and i get this error..

Error

src/print.cpp
src/print.cpp: In member function 'void PrintClass::print(unsigned char)':
src/print.cpp:4:12: error: 'write' was not declared in this scope
write(data);
          ^
src/print.cpp: In member function 'void PrintClass::print(char*)':
src/print.cpp:13:22: error: 'write' was not declared in this scope
write(string[index]);
                   ^
.build/uno/Makefile:47: recipe for target '.build/uno/src/print.o' failed make: *** [.build/uno/src/print.o] Error 1
Make failed with code 2

i have referred default arduino libraries like hardwareSerial and LiquidCrystal and i made my library like that but i cant get rid of that.
Please Help me.

user4143: Any functions that the base class needs to call that will be defined in the child class must also be defined in the base class.  They should be defined "virtual" so they can be overridden, and can even be "pure virtual" so they have to be defined in the child class.
So for any function in the child class that the base class needs to access, add this to the base class's definition (print.h):
virtual void write(unsigned char data) = 0;

The = 0 bit defines it as pure virtual, and any classes than inherit this class without defining their own copy of the void write(unsigned char) function will thrown an error. 
Instead of pure virtual you can provide a default function that a child can override if they want to, which can be useful if most classes will work the same way (define it in the parent) but some want to do it differently (override it in the child), in which case you treat it like a normal class function but add the virtual tag.
The whole topic is called polymorphism and is an incredibly powerful system.  It's discussed in detail here: http://www.cplusplus.com/doc/tutorial/polymorphism/

10634: <p>I have made two libraries and one test program.I have made my custom uart library.first i have included all functions for printing in single uart library file.but then i have made print library for printing functions only.my files are listed below.i have not posted my code directly so it can be read separately.</p>

<p><a href="http://pasted.co/479b09a3" rel="nofollow"><strong>uart.h</strong></a></p>

<p><a href="http://pasted.co/6279fbae" rel="nofollow"><strong>uart.cpp</strong></a></p>

<p><a href="http://pasted.co/61714885" rel="nofollow"><strong>print.h</strong></a></p>

<p><a href="http://pasted.co/d085dcba" rel="nofollow"><strong>print.cpp</strong></a></p>

<blockquote>
  <p>Test.cpp</p>
</blockquote>

<pre><code>#include &lt;avr/io.h&gt;                                                          
#include "uart.h"

int main(){
    uart.start(9600);
    uart.print("Test");
}
</code></pre>

<p>and i get this error..</p>

<blockquote>
  <p>Error</p>
</blockquote>

<pre><code>src/print.cpp
src/print.cpp: In member function 'void PrintClass::print(unsigned char)':
src/print.cpp:4:12: error: 'write' was not declared in this scope
write(data);
          ^
src/print.cpp: In member function 'void PrintClass::print(char*)':
src/print.cpp:13:22: error: 'write' was not declared in this scope
write(string[index]);
                   ^
.build/uno/Makefile:47: recipe for target '.build/uno/src/print.o' failed make: *** [.build/uno/src/print.o] Error 1
Make failed with code 2
</code></pre>

<p>i have referred default arduino libraries like hardwareSerial and LiquidCrystal and i made my library like that but i cant get rid of that.
Please Help me.</p>
 4143: <p>Any functions that the base class needs to call that will be defined in the child class must also be defined in the base class.  They should be defined "virtual" so they can be overridden, and can even be "pure virtual" so they <em>have</em> to be defined in the child class.</p>

<p>So for any function in the child class that the base class needs to access, add this to the base class's definition (print.h):</p>

<pre><code>virtual void write(unsigned char data) = 0;
</code></pre>

<p>The <code>= 0</code> bit defines it as <em>pure</em> virtual, and any classes than inherit this class <em>without</em> defining their own copy of the <code>void write(unsigned char)</code> function will thrown an error. </p>

<p>Instead of <em>pure</em> virtual you can provide a <em>default</em> function that a child <em>can</em> override if they want to, which can be useful if most classes will work the same way (define it in the parent) but some want to do it differently (override it in the child), in which case you treat it like a normal class function but add the <code>virtual</code> tag.</p>

<p>The whole topic is called <em>polymorphism</em> and is an incredibly powerful system.  It's discussed in detail here: <a href="http://www.cplusplus.com/doc/tutorial/polymorphism/" rel="nofollow">http://www.cplusplus.com/doc/tutorial/polymorphism/</a></p>
