class « class « C Array Q&A

Home
C Array Q&A
1.bit
2.Byte
3.char
4.class
5.Development
6.Dimensional Array
7.dynamic
8.element
9.find
10.index
11.initialization
12.Integer
13.length
14.loop
15.memory
16.Operation
17.pointer
18.Print
19.size
20.Sort Search
21.string
22.struct
23.variable
C Array Q&A » class » class 

1. Marshal C# Class Array as Struct Array To C    stackoverflow.com

Here is my code:

[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct Foo
{
  UInt32 StartAddr;
  UInt32 Type;
}


[DllImport(DllName, EntryPoint="_MyFunc", CallingConvention = CallingConvention.Cdecl)]
static extern unsafe IntPtr MyFunc([MarshalAs(UnmanagedType.LPArray)] Foo[] Foos);


List<Foo> Foos = new List<Foo>();
Foo1 = new ...

4. hello everyone...addition of bytes which s declared as array in private of class    bytes.com

i wrote a program to add bytes in array in such a way that when i add zeroth byte of two array sum should retained and carry must be added to next addition of bytes(ie array index 1 bytes) this is program which i wrote using class #include #define N 2 typedef unsigned char byte; class Megaint { private: byte a[N]; ...

5. Thread safe array class    bytes.com

andreas.zetterstrom@gmail.com I'm implementing some different c++ classes which I want to be thread safe. All these classes contain lists or arrays of some kind. I'm using protected sections to make them thread safe. The question then is: how do you in a nice safe way pick values out of the list? The easiest way is to have a pair of Lock, ...

6. Arrays of smart pointers to base class    bytes.com

Rune Allnor Hi all. I am sure this is an oldie, but I can't find a useful suggestion on how to solve it. I have a class hierarchy of classes derived from a base class. I would like to set up a vector of smart pointers to the base class, and access the virtual functions of any class in the hierarchy ...

8. Why can't fixed arrays be in class?    bytes.com

I tried to put fixed array into class, but the C++ Compiler generates an error as syntax error of '{'. I don't find anything wrong. Fixed array is used to have a list of strings. For example class Test { public: Test(); ~Test(); private: static const char List_Strings[5][10] = { "abc", "def" }; }

9. How to create static array of template class object?    bytes.com

flowstudioLA@gmail.com I have a template class object that I use as a mesaging queue between threads. I use it as a static object that I initialize like so: foo.h class foo{ static LFQueue

10. class with two dimensional array as a member (I need help)    bytes.com

On May 13, 9:18 am, "Alf P. Steinbach" class A { private: size_t myN; std::vector size_t indexFor( size_t i, size_t j ) const { return myN*i + j; } public: A( size_t n ): myN( n ), myElements( n*n ) {} int at( ...

11. revise the sequence class to use a dynamic array    bytes.com

Hi there, I revised my sequence class, from the last homework to use a dynamic array to store items, i am getting an error and 4 warnings, i also provided my header file, as well as the implementation file, can someone please help me out hear, my brains are beyond fried now, highly appreciated 1>------ Build started: Project: Assignment3, Configuration: Debug ...

13. Deleting array of derived class    bytes.com

i had a question while i was reading the book "MEC++ chapter 3" in the book, he says this will not work. class BST { public: virtual ~BST() { cout << "BST" << endl; } }; class BalancedBST : public BST { public: ~BalancedBST() { cout << "BalancedBST" << endl; } }; void delete(BST array[]) { delete [] array; } BalancedBST ...

14. Copy Array of class pointer to another    bytes.com

FirmArray has only pointers to Firm's. When you talk about a pointer to floats, I assume you mean the floats are in the object Firm. From your post, it sounds like you delete FirmArray1, which in turn deletes the Firms which in turn delete the float array. This sounds like a problem of deleting the float array more than once. Don't ...

15. Bubble Sort with an array filled with classes.    bytes.com

Do you want to sort separately i.e. have two separate functions - one that sorts by cost, the other that sorts by species? This is fairly simple - you can copy and paste your code, and change getSpecies to getCost. Or do you want them sorted by species, and each subset of species sorted by cost? To do this, in your ...

16. Initiate array in class    bytes.com

17. Class, array inside constructor.    bytes.com

The compiler says that 'sprite' not 'Sprite' is undeclared. The class Sprite is declared in a header, I didn't show the whole code I have. The problem is that when I declare 'sprite' I do it in the constructor which means that it's temporary in that function? And then when i try to draw it within the funtion Draw it can't ...

18. pasing an array pointer and storing as a class member    bytes.com

(apologies for cross posting from the moderated group..i'm sure you understand) Hello, I'm passing an array into a Constructor and hoping to use it as a pointer and store it as a class member for future use. So far, I'm just causing crashes, psuedo code below: double block[8192]; foo = MyClass(block); //// MyClass { public: MyClass (double *blk) {// constructor inBlk ...

19. array as member of class    bytes.com

Hi! I've organized my code in different files - the declarations of global variables and methods are contained in a file global.hh (for compilation via makefile under Linux). In this file I included the following: extern const int dim; //dimension of the array class Particle{ public: double x[dim]; //particle position }; Since dim is defined in another file (where main() is ...

20. returning an array from a class via a method.    bytes.com

Thanks for the answers! I can't believe I missed that. I thought, at one time I had added the asterisk to the return type, but it still wouldn't compile. I tested it, and I was right. BUT! After removing the dereference from the returned name ( return *name; <-- That one ) it ran perfectly! I really appreciate the answers. Also, ...

21. static array as a class member    bytes.com

what is wrong with the code below, when i compile i get the following error: ld: Unresolved: myClass::myArray but when i dont use the keyword static while declaring the array, there is no problem. what is the story about static arrays in class *********************** #include using namespace std; class myClass{ private: int a; static int myArray[10]; public: myClass(); void display(); ...

22. how do you declare and use a static constant array inside a class    bytes.com

johnmmcparland Hi all, I would like to have a static constant array inside a class definition which would contain the number of days in each month (I am writing a Date class as an exercise). However my attempts so far have been unsuccessful. Take this Test class as an example // test.hpp #include #include using namespace std; #ifndef TEST_HPP ...

23. classes in arrays along with Monte Carlo Sim!! Help!!    bytes.com

Help!! A company has 20 machines which run 8 hrs a day. 4 personnel are on duty during the 8 hrs. When a mach. goes down, only 1 person can work them at a time. At times, more than 4 mach. are down at a time, while at other times all personnel are idle. How do I start to: Use a ...

24. Deep copy constructor needed for an class array within another class    bytes.com

ok then there's another problem. What if i want to copy values of a chessboard that is a pointer to a value that is a normal Chessboard? For example. line 1: Chessboard *pBoard = CurrBoard; line 2: Chessboard c2 = (*pBoard); // i need a deep copy of Currboard into c2..... will this work? I know c2 = CurrBoard will work, ...

25. Help with classes, dynamic arrays and pointers    bytes.com

P: n/a foker I have a file with a list of times in it in the form hh:mm:ss. The file starts with a single INT like 460. That int is the number of times in the file so I can size my dynamic array correctly. I had to create my array as a type string because of the colons in it. ...

26. multidimensional array initializer costruct class    bytes.com

Hello to all. I have a problem for initialize an Array multidimensional, therefore I have seen from the forum, but it does not work correctly. An Array of 1024 allocations for 2 channels would serve me (left and rigth). that is: double A [1024] [2]; myClass () { public: myClass() { s = 1024; A = new double*[s]; for (int i=0;i

27. Seeking some help with pointer/array notation wrt class members.    bytes.com

brzozo2@uwindsor.ca Hello, anyone knows if there is a way to use pointer notation instead of array when it comes to copying one object to another via a pointer of array to objects? Here is a very simple code to show what I mean: /* 2 classes, one holds the int number, other is a table which uses pointer to array of ...

28. how to form a pointer to the n'th element of an array which is a class member    bytes.com

I have struct X { double array[10]; }; I want to form a pointer to the 5th element of X::array. The type of the pointer should be "double X::*" or "double* X::*" or something along those lines. Here is the code I tried: struct X { double array[10]; double* ptr; }; int main() { double (X::* junk1)[10] = &X::array; // ok ...

29. using classes with input of an array of char    bytes.com

Hi Liam, I assume you meant "All arrays" anyway I would say that using a vector to hold a small fixed length array was using a sledge hammer to crack a walnut (i.e. way over the top). A pointer or reference to an array is no less messy than a pointer or reference to a vector class. Banfa

30. access object in array of pointers to dynamic array of class complex    bytes.com

jccorreu@gmail.com I'm taking in data from multiple files that represents complex numbers for charateristics of different elements. I begin with arrays of doubles and interpolate to get standard values in real and imaginary portions. To this end I have some dynamic arrays of doubles to hold the standardized individual rael and imaginary parts. double *ANreal, *ANimag, *BNreal, *BNimag, *CNreal, *CNimag; ANreal ...

31. How can I make a Two-Dimension array of classes by operator overloading?    bytes.com

adc++ wrote:[color=blue] > Hi > Imagine that I have two classes one columns and one rows. > I want to can call a class-pointer that is in the rows with this call: > man [5][4] > how can I do it? > I know that I must overload [] but this have two dimensions. How can I > do it?[/color] I ...

32. Can a class have a non-static const array as a data member?    bytes.com

partha.p.das@gmail.com Here is my class: class MyClass { public: MyClass(); ~MyClass(); private: // non-static const array as a data member const int memArr_[5]; }; Is such a class (with non-static const array as a data member) valid? Since I cannot see why it may not be valid, I presume that it is valid. Therefore when an object of MyClass is constructed, ...

33. Zero sized arrays in base classes?    bytes.com

P: n/a fabio@nospam.it Hello, zero-sized arrays (which I find very useful, since I do a lot of packet-style programming with circular buffers) cannot be declared if they're in a struct/class that later will be inherited (i.e. in a base class), we know. In ANSI C++ you can't actually instantiate such a structure, if I'm not mistaken. Example: struct MyBaseClass { char ...

34. accessing const array reference in inherited-templated class    bytes.com

Hi, I got an error with gnu C++ but not with intel C++ (icc). The distilled code is given below, a variable "T" is stored as a const T& in the base class and when the derived class try to access it, the compiler gives an error. Compile error with gnu C++ and version of C++ compiler is also given below. ...

35. Very Fast Dyanmic Two Dimensional Array Class for Critical Review    bytes.com

// // Array2D.h 2005-11-27 5:50 AM // #define UINT unsigned int // // // class ArrayType2D { private: int Width; int Height; int Size; UINT* Array; bool Allocated; void Copy(ArrayType2D& Array2); public: ArrayType2D(); ArrayType2D(ArrayType2D& Array2) { Copy(Array2); }; ~ArrayType2D() { if (Allocated) delete [] Array; }; UINT& operator()(const UINT ROW, const UINT COL) { return Array[ROW * Width + COL]; } ...

36. calling struct class within array    cboard.cprogramming.com

struct student { char naam[25]; struct datum gebdatum; int resultaat; }; void DrukStudent(struct student s) { /* naam en gebdatum (dd/mm/jjjj) afdrukken */ printf("%-10s",s.naam); DrukDatum(s.gebdatum); printf(" %d%%",s.resultaat); } double gemiddelde(struct student studentrij[ ], int aantal) { int i; double result=0.0; printf("\ntest array\n"); DrukStudent(studentrij[1].resultaat); /* here is the problem */ return result; } void main() { struct student studentrij[20] = {{"Anton",{25,4,1988}, 75},{"Bert",{24,5,1987}, ...

37. Creating array of class objects using DMA    forums.devshed.com

Creating array of class objects using DMA Can you please tell me what's the mistake here? Code: #include #include #include typedef unsigned int uint; class HalfAdder; class FullAdder; uint bin_array_error = 0; // global variable to signal an overflow in the binary representation /*********************************************************************** * Note that at the location where the logic functions are called * (or practically anywhere in ...

38. Multidimensional dynamic array of pointers to class - Messed up    forums.devshed.com

hi all. i've been trying to understand this but can't see it yet, i need to create a 2d map for objects, the data for that is on struct TexArea. i'm trying to create a 2 dimension array to a pointer to that struct. so i declared: TexArea*** areas; and initialized it like this Code: areas = (TexArea***)calloc(MAP_AREA_MAX, sizeof(TexArea**)); for(int i ...

39. Assigning an array different values in a base class    forums.devshed.com

in this simple test program u can see that the derived class constructor changes the value of x to 88, but it doesnt change the array to the new values declared in the constructor also following the same format as declaring x an integer in the base class field and not redeclaring it an int in the base , i would ...

40. Newb C# question related to classes/arrays    forums.devshed.com

I'm still trying to wrap my head around the basics of c# and OOP. say i have a class file with: class Book { public string Name; public string Author; public int ID; } There are multiple books, so (I think) I want an to have an global array of books available to the program for various uses. I know I ...

41. Array Of Class Objects    forums.devshed.com

42. Array of Superclass    forums.devshed.com

Hello folks I'm trying to do my assignment and I'm really stuck in! I have to classes..Customer and Pensioner (Customer = Super class and Pensioner = Subclass) The Pensioner has a PensionNo extra than Customer class. I have to make a array of Customer class (for 10) and put Customer and Pensioner in it. Then I have to override << operator ...

43. Array with const size in a class?    forums.devshed.com

44. Structures, Arrays, Classes... what to use in my case? I'm confused :(    forums.devshed.com

Greetings! I'm converting my old PureBASIC app to C#, I really loved the way it would use "Structures" to hold "Array data". For example, in PB I could do... Structure Info User.s ; String Warnings.l ; Long integer EndStructure Dim UserInfo.Info(2000) And for accessing/writing I could do, for example: UserInfo(8)\User="John" UserInfo(8)\Warnings=1 Basically an array with multiple data types inside. Now I've ...

45. Implementing an array of a class    forums.devshed.com

hey im a newbie to c++ programming, i got this program as an assignment declare a class product with necessary public member functions and the following private data members: code,quantity(int) name(string) price(double) create an array of product with MAX(constant) elements write a menu driven program to input values display values sort on product code(selection sort) search for a product on product ...

46. Dynamic array in class    forums.devshed.com

> The code compiles fine, but crashes once it gets to the for loop within the constructor. The first step (see below) is to create a minimal example of the problem code and try that in isolation. Essentially, just the function in question and a main() to call it. The likely reality is that the problem is really elsewhere in the ...

47. Array of class objects    forums.devshed.com

Hello all. I am new to C++ and I just have a couple questions. Im working on a version of the game of life which can be found here ... First off, I am reading a file which contains 1's and 0's, creating an object for each 1 or 0, and then putting all of the objects into an array. I ...

48. class array problem.    forums.devshed.com

I encoutered a problem and can't solve it: in main() hformation *fdatah; fdatah=new hformation(); then sent it to a function: formationinput(vformation *fdatav,hformation *fdatah,ptfilein); in the function, I redefined this class pointer as an class array: fdatah=new hformation[7]; passed compile and link, but each time debug to here got error: Unhandled exception at 0x00433520 in forwardso.exe: 0xC0000005: Access violation reading location 0x00000000. ...

49. A class to contain a dynamic array of structs    forums.devshed.com

#include using namespace std; typedef vector DLArray; int main(void) { DLArray foo; DataLine bar; for (int i = 1; i < 10; i++) { SetDataLineValue(&bar); // Do something to set bar properly foo.push_back(bar); // Add to the array } for (int i = 0; i < foo.size(); i++) { // do something with foo[i]; } return 0; }

50. Quicksort array of class objects    forums.devshed.com

I'm working on yet another class project. To give some back ground, I have to modify a previous project to sort a dynamically sized array using a quicksort algorithm, and the quicksort function must be a template function so it could sort arrays of any data type. The original project involved reading in a list of names from a file and ...

51. Class program 40-element array    forums.devshed.com

52. Allocating memory for an array of classes question    forums.devshed.com

Never use malloc for classes as the memory is uninitialized. new will always call the constructor (and delete will call the destructor). There are several posts regarding dynamic multi-dimensional arrays, a search of the archives will probably turn up a few examples. Please use "code" tags when you post code, see the sticky post for new users (you may also find ...

53. Array of class objects help...    forums.devshed.com

55. boolean array in class problems...    forums.devshed.com

#include"Borrower.h" #include"date.h" class Loans{ Borrower laptops[26]; boolean findBorrowers[25] = {false}; public: void booking(Borrower student,int laptop){laptops[laptop] = student;} void laptop_list(void); char *Loans::laptopBorrower(int searched); int loanedLaptop(char *name); void findBorrower(char *search); }; void Loans::findBorrower(char *search){ char *found; for(int counter = 1 ; counter < 26 ; counter++){ found = strstr (laptops[counter].getName(),search); if (found != NULL){ findBorrowers[counter] = true; } } }

56. how to delete class in array    forums.devshed.com

57. Question about dynamically allocated array in a class    forums.devshed.com

// Constructor dynamically allocates an array of integers to hold the // program instructions and data. The total size of the array is given // by "memSize". The instructions are contained in the array "program" // which consists of "programSize" numbers. The instructions in the // "program" array are copied into the private "memory" array starting // at position 0. The ...

58. Class to add two boolean arrays or 1 boolean array with a int    forums.devshed.com

Hi folks, I am trying to write a C++ class where i can add or subtract 2 seperate boolean arrays. If you look at my code, where I overload the first + operator, I get an error here because while performing the OR operation, I am trying to map a BOOL value into the class SETS value. So the compiler is ...

59. Arrays and classes help    forums.devshed.com

I have the following code which compiles and allows you to create nonsense sentences. I need to make this object-oriented. I am stuck getting started. How do I pass the values (10 verbs and 10 nouns in two multi-dimentional arrays) to a class member function without using multi-dimentional arrays? #include #include #include // for rand() #include // ...

60. Need Some Help Please Arrays and Classes    forums.devshed.com

Here is the problem.. I need read a datafile into an array of class voter.. I can get it to store the information into the arrays if i have users enter information.. the problem im having is reading a file into an array of voter: #include "fileutil.cpp" #include #include #include #include #if !defined(microsoft) #include #define cls() system("cls"); #endif class Voter { ...

61. arrays or classes?    forums.devshed.com

Greetings all, I'm currently working on a command line app(for windows) than seaches from the current directory down recursively and garhers information on files. Currently, the only information is the file location. Is really simple as I'm not a C expert. Ultimately the purpose of the program is to search the directories, see which files are html and php, open them ...

62. Arrays of template classes    forums.devshed.com

hi, not sure if u can do the above, but i could offer another option that i think would work. maybe you already knew this, but here it goes anyways: -make a base class, and then derive children for each different data type(vector, int, double). then u can just make an array of base class pointers, and call each method polymorphically. ...

63. comparing character arrays from a class and from main    forums.devshed.com

comparing character arrays from a class and from main ive become frustrated with this application im trying to solve and would be most grateful if someone could help. im designing an application which will enable a user to enter marks for a module and work out their result. Data for a module is stored in a file. Most of it is ...

64. Array of Class    forums.devshed.com

How do you implement an array of classes. I have created a class. I then defined an array of that type. But I can't figure out how to access the data members I want to. Let's say my class is called "people." I defined an array people webdesigners[25]; If I have a member function called "getnames" I know that I can ...

65. Array of Struct or Class    forums.devshed.com

What is the proper way to implement an array of a struct or class. I have made a struct or class called students. Then I declared students gradclass[25] I am inputting info about students. For some reason it will not let me use single line cin to input into two variables for ex cin>>x>>y; I intially had it wrong. I initially ...

66. 2 dimensional array class    daniweb.com

i am having trouble iwth this question i am a little weak with classes that is why i cant complete this any help would be greatly appreciated Create a class for airline reservation. Assume that there are two aircraft models A, B. The class has following constants defined, const int col_number = 4; const int row_numberA = 20; const int row_numberB ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.