[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 580: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 636: sizeof(): Parameter must be an array or an object that implements Countable
3.14.by forum • Stackoverflow thing
Page 1 of 1

Stackoverflow thing

Posted: Sat Aug 28, 2010 3:20 am
by BarsMonster
Hi guys, if any of you have stackoverflow.com account,
Could you please go there : http://stackoverflow.com/questions/3589 ... ge-you-use
And vote for reopen/voteup it please? I really need feedback on that topic, and stackoverflow have perfect audience for that :crazy:

Re: Stackoverflow thing

Posted: Sun Aug 29, 2010 6:01 am
by LordMike
I must admit, that I kinda am able to follow their arguments against posting that on Stackoverflow.
But .. Alas, I'll help you here :)

You should check into LINQ of C#/VB/.Net. It's an ingenious language element, Integrated Queries. Allows you to query objects in-memory as well as in a database. :)

EDIT:
For example, instead of this, normal way to do it in C#:

Code: Select all

SqlConnection conn = new SqlConnection("server=...;user=...");
SqlCommand com = new SqlCommand(conn, "SELECT...");
SqlDataReader rd = conn.ExecuteReader();

while (rd.Next())
{}

rd.Close();
conn.Close();
You could do this (assuming you've done the pre-work of setting up the data entities:

Code: Select all

var temp = from a in db.[table] where a.ID == 1 select a;
Or you could use it as objects:

Code: Select all

var temp = db.[table].single(x => x.ID == 1);
There are many fascinating ways to use LINQ in. Just ask :)

Re: Stackoverflow thing

Posted: Mon Aug 30, 2010 12:27 am
by Sc00bz
Dynamic creation of an array of classes using a non default constructor.

Code: Select all

class SomeClass {public: SomeClass(int);};
...
	int useNonDefaultConstructor = 0;
	SomeClass *sc = new SomeClass(useNonDefaultConstructor)[5];
...
------------

I'm pretty sure there is no way to do this in c++. Well besides using global variable(s) or an array of pointers to a class.

Code: Select all

class SomeClass {public: SomeClass(int);};
class SC : public SomeClass
{
public:
	SC() : SomeClass(s_param) {}
	static int s_param;
};
int SC::s_param = 0;
...
	SC::s_param = 0;
	SomeClass *sc = new SC[5]; // this should soooooo be a warning and an error when sizeof(SC) != sizeof(SomeClass) but it's not
...
------ or ------

Code: Select all

class SomeClass {public: SomeClass(int);};
...
SomeClass **sc = new SomeClass[5];
for (a = 0; a < 5; a++)
	sc[a] = new SomeClass(0);
...