Stackoverflow thing

Moderator: BarsMonster

Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
User avatar
BarsMonster
Site Admin
Posts: 1118
Joined: Wed Oct 01, 2008 7:58 pm
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Stackoverflow thing

Post by BarsMonster » Sat Aug 28, 2010 3:20 am

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:

User avatar
LordMike
Posts: 184
Joined: Tue Feb 10, 2009 8:34 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: Stackoverflow thing

Post by LordMike » Sun Aug 29, 2010 6:01 am

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 :)

Sc00bz
Posts: 136
Joined: Fri Oct 03, 2008 8:28 am
Contact:

Re: Stackoverflow thing

Post by Sc00bz » Mon Aug 30, 2010 12:27 am

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);
...

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Who is online

Users browsing this forum: No registered users and 1 guest