I want to make a program in C++ that reads a file where each field will have a number before it that indicates how long it is.
The problem is I read every record in object of a class; how do I make the attributes of the class dynamic?
For example if the field is "john" it will read it in a 4 char array.
I don't want to make an array o...
Here's a very simple example of what I'm trying to get around:
class Test(object):
some_dict = {Test: True}
The problem is that I cannot refer to Test while it's still being defined
Normally, I'd just do this:
class Test(object):
some_dict = {}
def __init__(self):
if self.__class__.some_dict == {}:
se...
Hello,
i'm a very new user to flex (never use flex, nor flashbuilder, nor action script before), but i want to learn this langage because of the beautiful RIA and chart it can do.
I watched the video on adobe : 1 hour to build your first program but i'm stuck :
On the video it says that we have to provide a PHP class for accessing da...
>>> class Abcd:
... a = ''
... menu = ['a', 'b', 'c']
...
>>> a = Abcd()
>>> b = Abcd()
>>> a.a = 'a'
>>> b.a = 'b'
>>> a.a
'a'
>>> b.a
'b'
It's all correct and each object has own 'a', but...
>>> a.menu.pop()
'c'
>>> a.menu
['a', 'b']
>>> b.menu
['a', 'b']
How could this happen?
And how to use list as class attribute?
...
Hello,
I'm sorry, but a while ago I wrote a piece of code that was so nice. And now I'm trying to remember it for a new project.
All I can remember about it is that it looked something like this:
public static Create<T>() *something missing here* : *Something missing here*
{
// add methods etc here. I also think I remember someth...
I'm trying to change the method OnAuthorization, so that it is available for any application ... this way:
public partial class Controller
{
protected override void OnAuthorization(AuthorizationContext filterContext)
{
if ((string)(filterContext.RouteData.Values["action"]) == "test")
{
filterContext.R...
Hello,
Suppose we have some class A that implements some interface I
I i = new A();
i.method(); // example 1
A a = (A)i;
a.method() // example 2
The IL code generated for each call to "method()" is same, but which one of invocations to method "method()" have more cost in native code and why?
Any help will be appreciated.
...
I have Python classes, of which I need only one instance at runtime, so it would be sufficient to have the attributes only once per class and not per instance. If there would be more than one instance (what won't happen), all instance should have the same configuration. I wonder which of the following options would be better or more "idi...
Simple question, how do I convert an associative array to variables in a class? I know there is casting to do an (object) $myarray or whatever it is, but that will create a new stdClass and doesn't help me much. Are there any easy one or two line methods to make each $key => $value pair in my array into a $key = $value variable for my cl...
What is wrong with this code?
<?php
class users {
var $user_id,
$f_name,
$l_name,
$db_host,
$db_user,
$db_name,
$db_table;
function users() {
$this->$db_host = 'localhost';
$this->$db_user = 'root';
$this->$db_name = 'input_oop';
$this->$db_table = 'users';
}
function userInput($f_name, $l_name) {
$dbc ...
For the C++ code fragment below:
class Foo {
int a[]; // no error
};
int a[]; // error: storage size of 'a' isn't known
void bar() {
int a[]; // error: storage size of 'a' isn't known
}
why isn't the member variable causing an error too? and what is the meaning of this member variable?
I'm using gcc version 3.4.5 (mingw...
Hi. I have a requirement of creating java classes dynamically and make it accessible different jvms across the network. I tried to use reflection and javassist tool,but nothing worked. Let me explain the scenario
we are using Coherence distributed cache. It has a power of doing aggregation/filtering in parallel across the cluster. For ex...
I dont know much about classes, but have a reasonable knowledge of PHP/MySQL.
But why should I learn classes? I know they are important but what benefits can I see using them that I cant with?
...
Looking at various pages in the Android docs, some of them list "Known Indirect Subclasses". What does this mean?
...
Hi. I am teaching myself to write classes in C++ but can't seem to get the compilation to go through. If you can help me figure out not just how, but why, it would be greatly appreciated. Thank you in advance! Here are my three files:
make_pmt.C
#include <iostream>
#include "pmt.h"
using namespace std;
int main() {
CPMT *pmt = n...
Dear all
I have a doubt related to class. For example
class A
{
public:
A()
{
.....
.....
}
void cleanup()
{
....
....
....
}
public:
UINT a;
ULONG b;
};
In the above example there are two public section, In first section i am defining constructor and the method and in the second section i am declaring data members. Does the above ...
So ive got a base class which requires a Socket:
class Sock
{
public Socket s;
public Sock(Socket s)
{
this.s = s;
}
public virtual void Process(byte[] data) { }
...
}
then ive got another class. if a new socket gets accepted a new instance of this class will be created:
class Game : Sock
{
publi...
Using the standard VS IDE, is there a fast way to create class properties that are linked to the local variables?
The class diagram seems to provide something, but it basically just created a property stub. Is there something better / easier out there ?
...
We know that compiler generates some member functions for user-defined class if that member functions are not defined but used, isn't it. So I have this kind of code:
class AA
{
};
void main()
{
AA a;
AA b(a);
a = b;
}
This code works fine. I mean no compiler error. But the following code....
class AA
{
int member1;
...
I want to separate the output of HTML from my program code in my projects, so I wrote a very simple database class.
<?php
class Template
{
private $template;
function load($filePath)
{
if(!$this->template = file_get_contents($filePath))
$this->error('Error: Failed to open <strong>' . $filePath . '</stron...