Hey guys!

I am newbie to this, I'm in need for help in my C++ project, I seem to be getting this error and have no idea why it keeps saying the same thing, i created header and cpp files but this error is annoying me:

projectnew.obj : error LNK2005: "class sqlform2 cmd" (?cmd@@$$Q3Vsqlform2@@A) already defined in form2.obj
C:\Users\abugslife\Desktop\backup - Copy (V4)\projectnew\Debug\projectnew.exe : fatal error LNK1169: one or more multiply defined symbols found


Any help would be much appreciated thanks!

Recommended Answers

All 3 Replies

Better show us the code..

You probably have the implementation of this class in two .cpp files

This is my .h file:

#ifndef __SQLFORM2_H__
#define __SQLFORM2_H__

#include "stdafx.h"


using namespace System::Data::SQLite;
using namespace System::Data;
using namespace System::Windows::Forms;

class sqlform2
{
public:

	void add(System::String ^ProductName, System::String ^Size, System::String ^Style, System::String ^Colour, System::String ^Price, System::String ^InStock, DataGridView ^dataGridView1);




private:
	
protected:
};

#endif

This is my .cpp file:

#include "stdafx.h"
#include "sqlform2.h"

using namespace System;
using namespace System::Data::SQLite;
using namespace System::Data;
using namespace System::Windows::Forms;

void sqlform2::add(System::String ^ProductName, System::String ^Size, System::String ^Style, System::String ^Colour, System::String ^Price, System::String ^InStock, System::Windows::Forms::DataGridView ^dataGridView1) {

//ive got my sql functions here//

this is my code for the function of adding data to my form for the above stuff:

private: System::Void button1_Click_1(System::Object^  sender, System::EventArgs^  e) {

			String^ ProductName = textBox1->Text;
			String^ Size = textBox2->Text;
			String^ Style = textBox4->Text;
			String^	Colour = textBox5->Text;
			String^	Price = textBox6->Text;
			String^	InStock = textBox11->Text;

			cmd.add(ProductName, Size, Style, Colour, Price, InStock, dataGridView1);
			
		 }
};

This is the code for same form of the above code but the top part

#pragma once

#include "sqlform2.h"


using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Data::SQLite;

	sqlform2 cmd;

namespace projectnew {

thanks for checking!

Hey mate no worries! I trustworthy friend of mine worked it out for me!! :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.