I've wrote a quick PHP class to ease the access to a mysql database. The class works ok, and has a query() method that opens up the connection, executes the query and then closes the connection (I know that the connection is supposed to close by PHP itself after the script finishes, but I don't like to rely very much on that).
From a pe...
Does it have any drawbacks if I use Object as a name for my class inside module?
module Some
class Object; end
end
...
I'm in the process of creating a double-linked list, and have overloaded the operator= to make on list equal another:
template<class T>
void operator=(const list<T>& lst)
{
clear();
copy(lst);
return;
}
but I get this error when I try to compile:
container_def.h(74) : error C2801: 'operator =' must be a non-static member
...
I know it's possible to create a friend function in C++:
class box
{
friend void add(int num);
private:
int contents;
};
void add(int num)
{
box::contents = num;
return;
}
But is there a way to create friend classes?
NB: I know there are probably a lot of errors in this code, I don't use friend functions and am still pretty new to ...
I know the questions seems ambiguous, but I couldn't think of any other way to put it, but, Is it possible to do something like this:
#include<iostream>
class wsx;
class wsx
{
public:
wsx();
}
wsx::wsx()
{
std::cout<<"WSX";
}
?
...
I was playing around with my MSVC++ compiler, and the properties tab for my point class said:
IsAbstract - false
IsInjected - false
IsManaged - false
IsSealed - false
IsTemplate - false
IsValue - false
What do these mean, and why were all of them greyed out except IsAbstract and IsSealed?
...
Hey there, quick question here. I'm sure there's a simple answer.
Coming from PHP, I'm used to declaring a function with a default argument value like this:
function myFunction ($array, $sort = FALSE) {
}
I the sort parameter wasn't filled, the function would continue with the default value of false. In Obj-C, is there a similar t...
Here's a constructor for my Game class:
// Construct a Game to be played with player on a copy of the board b.
Game(const Board& b, Player* player)
{
...
}
Here's how I'm using the constructor:
Player p("Player Name");
Board b(6,3);
Game g(b, &p);
How does this work? Is b being copied?
If I want to save a pointer to player, shou...
Hello,
I have a class with a complex data member that I want to keep "static". I want to initialize it once, using a function. How Pythonic is something like this:
def generate_data():
... do some analysis and return complex object e.g. list ...
class Coo:
data_member = generate_data()
... rest of class code ...
The func...
I'm doing my first javascript project that makes heavy use of objects. Because of how it works, nearly all the custom objects are done like this:
namespaceobj = {};
namespaceobj.subobject = {};
namespaceobj.subobject.somefunction = function(arg, uments) {
// Do Stuff
}
namespaceobj.subobject.somedata = 10;
namespaceobj.othersubject ...
If you're supposed to encapsulate everything inside a class definition, how is it then possible to use enumerated data types with the class? For example I've just written the following code...
enum PizzaType {DEEP_DISH, HAND_TOSSED, PAN};
enum PizzaSize {SMALL, MEDIUM, LARGE};
class Pizza {
public:
Pizza();
void set...
I have code that looks like this:
template<class T>
class list
{
public:
class iterator;
};
template<class T>
class list::iterator
{
public:
iterator();
protected:
list* lstptr;
};
list<T>::iterator::iterator()
{
//???
}
I want to make the constructor of list::iterator to make iterator::lstptr point to the list it's ...
I want code to run whenever I create a new object. For example, see this:
<?php
class Test {
echo 'Hello, World!';
}
$test = new Test;
?>
I want it to echo "Hello, World!" whenever I create a new instance of this object, without calling a function afterward. Is this possible?
...
For example, if let's say I have a database of users. I have a class that gets information form the database about these users.
I want to make the class "self aware" of it's own name, like this:
<?php
class UserData {
//[code that fetches the ID number from the variable name, and queries the database for info]
}
$user24 = new UserD...
I'm trying to write a class that when asked on, will call on a class and make it into a class member. Here's a quick example of what I mean:
class foo{
myClass Class;
foo();
};
foo::foo()
{
//Create the class and set it as the foo::Class variable
}
I'm sure this is actually an easy thing to do. Any help would be appreciated
Tha...
When I started with Cocoa, I remember that I read somewhere that int/float and similar should not be used for class properties and to use NS* equivalents (like NSInteger).
Is there a real hidden issue here why would that be better or it was just a voluntary coding rule by a person where I read that (and I can't for the life of me find w...
Why is class based OO so popular instead of prototype based OO? Do they teach the latter in schools? Javascript is object based, but people use it mostly functionally, or via frameworks.
I know that Sun has had some research on Self, but is there any other source of knowledge; preferably something that is accessible for self learned.
I...
I'm building a plugin system for my application. I've read that anyone can decomple .class files and therefore I'm forced ot use a Ahead-Of-Time compiler (right?). The problem is that I need to load some plugin classes dynamically. Right now I'm loading all .class files in a folder and invoking a static method (I never create a object) a...
Here's the class im trying to store
[Serializable]
[XmlRoot(ElementName = "Database", IsNullable = false, Namespace = "http://somesite.com")]
class Database
{
[XmlAttribute(AttributeName = "Name")]
public string Name { get; set; }
[XmlAttribute(AttributeName = "Provider")]
public DatabaseProvider Provider { get; se...
I have a windows form with a data grid bound to a datatable.
On a button click, the data table is passed to a static class.
private void btnSave_ItemClick(object sender, EventArgs e)
{
MyStaticClass.SaveData(DataTable dt);
}
internal static class MyStaticClass
{
internal static void SaveData(DataTable dt)
{
foreach(D...