#include<iostream> using namespace std; class Singleton { static Singleton * s; Singleton() { } public: ~Singleton() { s = NULL; } static Singleton * getInstance(); void print() { cout<<this<<endl; } }; Singleton* Singleton::s=NULL; Singleton* Singleton::getInstance() { if(s == NULL) { s = new Singleton(); } return s; } int main() { Singleton * s = Singleton::getInstance(); s->print(); Singleton * s2 = Singleton::getInstance(); s2->print(); return 0; } Singleton* Singleton::s=NULL; (line 23) When I am not putting this line, it is saying that undefined reference to 's'. By default static members are NULL only. then why does it need me to put …

Member Avatar
Member Avatar
+0 forum 8

Hi All I use MS Access to import information from Excel, check for duplicates and post it to an Access data table. The amount of data is making this process extremely slow. I am attempting to move the data tables to MySQL and then running a Stored Procedure to do this task as I believe it should be a lot faster. I am finding it difficult to write the code for the SP. In MS Access the query looks like this: *INSERT INTO tbl_Costs ( Type, Reference, Description, BusArea, CostCentre, Tx, DocumentNo, Account, Period, CompanyCode, Username, SalesDoc, Item, DocDate, Amount, …

Member Avatar
Member Avatar
+0 forum 1

Hi guys, I'm running into an issue that's really frustrating me. It's probably the most common newbie oversight, causing me to get the dreaded NullReferenceException. I've encountered it many times before, but this time it's got me stumped. I'm filling a Datagrid with a table from a database. I'm able to get the data, and I put it into a class, which is then added to a List<T>, with each new object added a new element of the list. Once the list is built, I bind it to the DataGrid as an ItemsSource.. and that's where I encounter my issue. …

Member Avatar
Member Avatar
+0 forum 3

The End.