سلام
من یه کلاس دارم به صورت زیر :
#ifndef _TEST_H_
#define _TEST_H_
class test {
public :
}test1, test2, test3;
#endif
میخوام این کلاس ( که داخل فایل test.h هستش ) رو داخل یه فایل دیگه ( uart.h ) و فایل main استفاده کنم و فقط فایل رو include کنم و از شیء های از پیش تعریف شده استفاده کنم - مثلا از شیء test1 در فایل main استفاده کنم و از test2 در فایل uart.h ولی خطای زیر داده میشه بهم :
.\Objects\1.axf: Error: L6200E: Symbol test1 multiply defined (by uart.o and test.o).
.\Objects\1.axf: Error: L6200E: Symbol test2 multiply defined (by uart.o and test.o).
.\Objects\1.axf: Error: L6200E: Symbol test3 multiply defined (by uart.o and test.o).
برا حل این مورد تو فایل test.h اومدم اون object های از پیش تعریف شده رو static تعریف کردم که خب خطای فوق رفع شد ولی نمیدونم این کار درسته یا نه.
#ifndef _TEST_H_
#define _TEST_H_
class test {
public :
};
static test test1;
static test test2;
static test test3;
#endif