C# :: Package Methods In Struct

Oct 20, 2012

Is it common practice to package methods with other elements(string-s, int-s, float-s, array-s...) of struct?

Than struct acts as a class or is acting similar to class and that have no sense to me? I am new to OOP .

View 4 Replies


ADVERTISEMENT

C++ :: Program For Billing System - Regular Package Function

Jan 5, 2015

I have programmed a program for billing system. I have used parameters and arrays. All the functions are working except a one function. (Regular package function).

#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
using namespace std;
void main(int &minutes, int &minutesd,int &minutesn) {

[Code] .....

View 3 Replies View Related

C++ :: Tourist Agency - Calculate Total Price For Customers For A Package Of Vacation?

Apr 25, 2013

SYNOPSIS : KBJ tourist agency Sdn. Bhd wants you to write an application program to calculate the total price for their customers for a package of vacation. The following table shows the price for three destinations (transportation and accommodation) offered by the agency:

Destination TransportationAccommodation
Pulau Redang Child RM15.00
Adult RM30.00RM95 per day
Pulau Perhentian Child RM20.00
Adult RM30.00 RM100 per day
Pulau Kapas Child RM10.00
Adult RM20.00 RM120 per day

This agency company will give some discount to a group of customers with is:

a.10% discount will be given for the group that has a least 5 adults.

b.25% discount will be given for the group that has more than 5 persons (adults and children)

c.30% discount will be given for the group that has at least 15 persons.

Your application program has to display the output using this following screen layout:

KBJ TOURIST CUSTOMER INFORMATION

Customer’s name: XXXXXXXXXXXXX
Number of Children:XXXXX
Number of Adult: XXXXX
Transportation: RMXXX.XX
Accommodation: RMXXX.XX
Total price: RMXXXX.XX

This is the code i got so far but it doesn't work..:(

#include <iostream.h>
int main () {
char customerName,code,A,B,C;
int childNum,adultNum;
double rate,discount,totalPrice,a,c;

[Code] .....

View 8 Replies View Related

C/C++ :: Sizeof (struct) Returns 6 More Bytes Than Actual Struct Size?

Sep 14, 2014

#include <stdio.h>
#define MAX_USERS 20
struct {
char ID[10];
char Name[40];
int Pos;

[Code] .....

I was attempting something weired with address to move data around when I discovered that the size of the array is not what I expected. I am passing this structure as &Users to a function that declares it as a void *, then I can deal with chunks of data (memmove) and not have to worry about index or things like that. However...sizeof is returning something I do not understand.

View 9 Replies View Related

C++ ::  Virtual Methods With MI

Jan 6, 2014

I have questions about multiple inheritance and virtual methods. I have a class called solid. All objects of this class have hitboxes and can collide with others. I have the following methods:

void testCollision(something begin, something end);
/* This method takes a container's begin and end iterators to test if the object collides with any other object of the list of all the solids currently in the game area. Each time there is a collision, it calls collide(other) and other.collide(*this) */

virtual bool collide(solid& other);
/* This method always returns false and does nothing */

This class will be inherited by another class which will have overloads for a few specific collisions. For example:

class player : public solid{
public:
bool collide(projectile& other);
bool collide(enemy& other);
bool collide(wall& other);
};

My question is quite simple actually. If I have a loop which calls testCollision() with all elements in the list of all solids (a list of pointers to solids to be exact) and there is a collision between the player and a projectile, will testCollision call player::colide(projectile& other) or will it call solid::collide(solid& other). And in any case, did I understand how to use the virtual keyword? If I'm right, it should call the player::colide method if it's there for the specific type, else it will call the solid::colide which only returns 0, ignoring collision.

View 4 Replies View Related

C++ :: CPP File With Methods

Feb 15, 2012

I have h-file with definition of 3 classes. And cpp-file with realization methods of this classes. And when I compile the project errors - LNK2019 is apperead... How make that methods become visible?

View 1 Replies View Related

C++ :: Delete All Parent Methods Of A Given Name?

May 7, 2013

I'm writing a sorted vector implementation and trying to do it as simply as possible.

Right now, I'm declaring the sorted vector with a protected subclass of vector, then using the "using" keyword to explicitly inherit all methods that aren't related to adding new elements to the vector (so I can control the order).

Eg:

Code: template<typename T, class Cmp = std::less<T>>
class sorted_vector : protected std::vector<T>{
public:
typedef typename std::vector<T>::iterator;
using std::vector<T>::operator=;
using std::vector<T>::assign;
using std::vector<T>::get_allocator;
using std::vector<T>::at;
using std::vector<T>::operator[];
//...
};

Obviously, this is annoyingly redundant. So what I'd like to do is something using the new "delete" keyword from C++11. Is there any quick, expressive way of deleting specific methods?

Also, it's pretty annoying to have to typedef base_class::type type to inherit a type from a base class. Is there a shorter way to do that?

View 14 Replies View Related

C++ :: Accessing Setter Methods

Nov 21, 2013

How to i access setter from within a setter?

I know that getter methods can be access like

Code: getAccounts().getAccountNumber();

// for example but for setters how do i do it? this doesnt seem to work though

Code: setAccounts().setAccountNumber(accountNumber);

View 7 Replies View Related

C++ :: How To Call Methods Of Class

Feb 27, 2014

how to call the methods of the class.I have an object call v which is an array and I don't how to call the methods of the class. The error is here:

v.readDates(v[a]);

#include "Date.h"
#include <iostream>
using namespace std;
int main(){
int a;
cout << " HOW MANY DATES DO YOU HAVE? " << endl;

[code]....

View 3 Replies View Related

C++ :: Add And Overwrite Class Methods Through Lua

Oct 9, 2013

I'm using lua 5.2.2 with luabind 0.9.

I'd like to be able to add additional class-methods through lua for any classes that I've bound in c++, but I'm unsure how to do it.

The problem is that luabind uses a function as the __index-metamethod for any bound classes instead of a table, so I don't see a way to access the class-methods at all.

e.g., I'm binding my classes like this:

luabind::module(lua) [
luabind::class_<testClass>("TestClass")
.def(luabind::constructor<>())
.def("TestFunc",&TestFunc)
];

What I essentially want to do is to add a lua-function to the list of methods for this class, and be able to overwrite existing ones:

local t = tableOfClassMethods
local r = t.TestFunc -- Reference to the c++-function we've bound
t.SomeFunction = function(o) end -- New function for all objects of this class
t.TestFunc = function(o) end -- Should overwrite the c++-function of the same name

View 2 Replies View Related

C++ :: Using Tea Algorithm Methods From Wikipedia?

May 8, 2013

i have been trying to call out the tea algorithm from wikipedia. However i keep getting a segmentation fault. Am i calling it out the wrong way? Below are the snippets

methods taken from wikipedia

void encrypt (uint32_t* v, uint32_t* k) {
uint32_t v0=v[0], v1=v[1], sum=0, i; /* set up */
uint32_t delta=0x9e3779b9; /* a key schedule constant */
uint32_t k0=k[0], k1=k[1], k2=k[2], k3=k[3]; /* cache key */
for (i=0; i < 32; i++) { /* basic cycle start */
sum += delta;

[code]....

i tried to encrypt a test text and casting it to the uinstd32_t type. However it always gives me a segmentation fault.

View 2 Replies View Related

C++ :: Difference Between Methods And Objects?

Feb 2, 2014

What is a method and what is an object?

View 8 Replies View Related

C++ :: Creating Methods For Class List?

Jul 3, 2013

Creating the methods for class List

main.cpp Code: #include "List.h"
int main( )
{
List la; // create list la
la.push_front( "mom" );
la.push_back( "please" );
la.push_back( "send" );
la.push_back( "money" );
la.push_front( "hi" );
cout << "
la contains:
" << la << '

[code]...

View 12 Replies View Related

C# :: Are Methods Stored In Heap Or Stack?

Jan 29, 2012

I know that memory addresses in the stack can contain either values or references to other memory addresses, but do these memory addresses also contain methods or are the methods themselves located in the heap?

The confusion comes from the fact that in C# a delegate variable can be assigned either a method's identifier, an inline function, a lambda expression, or a new instance of the delegate type with the method's identifier passed as an argument to the constructor. My guess is that assigning the method's identifier directly to the delegate variable is just a simplified way of calling the delegate type's constructor with the method's identifier as an argument to the parameter, something that the compiler handles for you.

But even in this last case, the delegate variable is said to point toward the method itself. In that case, does it mean that methods are stored in the heap, just as reference type values are?

View 2 Replies View Related

C++ :: Override Few Methods In FILE Class

Oct 30, 2013

I need to override a few methods in FILE class so i defined few methods as

EnCrpt * fp;
fp * fopen(const char * filename, const char * mode);
int fwrite(const void * p,int length,int readLenth,FILE * fpp = NULL);
int fread(void * p,int length,int readLenth,FILE * fpp = NULL);
int fseek(FILE * fpp = NULL,long offset, int whence);
long ftell(FILE * fpp = NULL);
int feof(FILE * fpp = NULL);
int fflush(FILE * fpp = NULL);
int fclose(FILE * fpp = NULL);

I will call fread method in my encrypted file class .. similar to other methods.. is this correct ? can NULL file pointer create issue ?

Because i have so many place where FILE class called i don't want to change everywhere to call encrypted file class so i am override these methods to encrypted file class instead of standrd FILE class

View 9 Replies View Related

C++ :: How Are Members Accessed In AMP Restricted Methods

May 17, 2013

Suppose I have a class "A", which has a method "void AMP_call()" that calls paralel_for_each in which another method, "float amp_function(float) restrict(amp)". When I call that method, can it then use members of "A"?

class A {
void AMP_call();
float amp_function(float) restrict(amp); // do something on a device
float allowed_variable;
std::vector<bool> not_allowed;

[Code] ....

Another way to frame my question, perhaps to make it easier to understand what I am after, would be that I want to know what happens if an amp-restricted method is called where the body of the class itself (which is not amp-compatible and afaik doesn't have to be since it's not passed to the device) may contain members that are not amp-compatible.

All of the msdn blogs I could find deal with which functions and methods can be called from within a parallel_for_each loop, but not with which variables are available to the lambda function itself.

View 9 Replies View Related

C# :: Windows Form Applications Using Methods?

Sep 30, 2014

I need to write a windows form application that allows the user to enter a credit card number and credit card type and then determines whether it is a valid number using the following rules:

1.) the first number is:

a. 4 for visa
b. 5 for master card
c. 37 for american express
d. 6 for discover

2.) passes the mod 10/ luhn check, which is calculated as:

a. from right to left, multiply every other digit by 2. when doubling a digit results in a two digit number, add the numbers to get

a single digit. ( like 6 * 2 = 12 therefore 1 + 2 = 3).

b. add all the single digits from 2a

c. add all the odd places from right to left in the card number

d. sum the results fro steps 2b and 2c

e. if the resulting number in 2c is divisible by 10, the card number is valid otherwise it is invalid.

The chapter is introducing methods so that is the main thing i will be using for each step.

View 1 Replies View Related

C# :: How To Combine 2 Methods To Make SQL Class

Jun 17, 2014

I am given 2 methods and they want me to create a stand alone class for sql that will change the sql string.

my question is how can i take these 2 methods and make one class out of them that will used on various other forms.

#1

public string AuthenticateWithDB(CUiPontisDatabaseSpecification pdb, string sUserId, string sPassword,
bool bCreatePersistentCookie)

#2

public static void ChangeConnection(Util.ODBC.ODBCDSN odbcInfo, CPonDatabaseVendorType dbType, string uid, string password)

they want it so they can use it like

CUiHttpSessionManager.SimpleDataConnectionString = SomeNewClass.CreateSimpleDataConnectionString()

where some new class is my new class

View 5 Replies View Related

C++ :: Template Classes And Inline Methods

Aug 17, 2012

I have a template class which defines a few heavy methods. For now, they are defined in the same .h file as the class definition, but i`d like to have them in a separate .cpp file.

A situation i find you describe in the FAQs arises: [URL] ....

Problem: the export keyword has been deprecated in c++0x, if i recall correctly, and has never been implemented in any of the compilers i am using (msvc, gcc).

#Including the the .cpp file after the class definition (as described in the second post of the FAQ) works.

another question: i have methods that dont use any template code. Can i somehow declare them as such? (more of an esthecial question, which would make it easier to distinguish between template and non.template code).

View 6 Replies View Related

C++ :: Char Arrays - Getting User Input Through Different Methods

May 29, 2014

I've been experimenting with char arrays and getting user input through different methods.

int main() {
char userInput[21];
/*I understand that over here, a maximum of 20 letters can be input, and only letters before a space will be stored in userInput*/
std::cin >> userInput;
std::cout << userInput << std::endl;

[Code] ....

As I was testing, whenever I would input a single word for userInput (for example "hi"), the program would work as expected: it would output "hi" and I'd be able to input a sentence of sorts for userInput2 (for example "hello world") and have it outputted.

But if I were to input more than one word for user Input (for example "hi how are you"), the program would output "hi" as expected, but it wouldn't let me input anything for userInput2 and would just output the rest of the first input; in this case, "how are you" would be outputted and the program would end. I am not aware of the logic error at play.

View 7 Replies View Related

C++ :: Read Variables And Methods Of Another Program In Memory?

Jan 16, 2013

i want to write a program that can access to variables and methods of another program. I ques for access to variables need to read memory, but about methods?how i can use methods and call them?

View 1 Replies View Related

C++ :: Compile Method Of Class Separately From Other Methods?

Apr 11, 2014

There is any method to compile a method of a class separately from the other methods and the main.

View 1 Replies View Related

C++ :: Repeated Handling With Different Methods Calls But Same Parameters

Apr 24, 2014

I have several functions doing similar things, inside their implementations, the parameters are the same, but they call different methods.

I want to create one function to make the structure easier, and reduce the duplication. I heard template might be one solution. But I am not sure how to use it in this case.

void GetA(...XXX) {
for()
{

[Code].....

View 1 Replies View Related

C# :: Creating A Class And Methods For Dice Game?

Mar 21, 2015

The only difficulty im having is creating a class and methods & being able to access them from my win form app. Can i get a few tips on the do's and donts of creating classes / methods and accessing them from form app.

This is what i have put together so far.

public partial class Form1 : Form {
private Image[] dicePics;
private int[] diceNum;
private Random randomize;
public Form1() {
InitializeComponent();

[code]....

View 3 Replies View Related

C++ :: Pure Virtual Methods And Interface Class

Jul 11, 2012

I develop add-ons for MS Flight Simulator and I use the poorly documented SDK for this. The SDK provides a .h file in which an interface class is defined (with pure virtual methods only), something like this:

Code:
class IPanelCCallback {
public:
virtual IPanelCCallback* QueryInterface (PCSTRINGZ pszInterface) = 0;
virtual bool ConvertStringToProperty (PCSTRINGZ keyword, SINT32* pID) = 0;
virtual bool ConvertPropertyToString (SINT32 id, PPCSTRINGZ pKeyword) = 0;
};

In my code, I use this interface like this:
Code:
IPanelCCallback* pCallBack = panel_get_registered_c_callback("fs9gps");
...
SINT32 id;
pCallBack->ConvertStringToProperty(propertyName, &id);

Everything works fine, but I don't understand why... I thought the linker would stop with an "undefined symbol" error because the IPanelCCallback methods, such as ConvertStringToProperty, are declared as pure virtual but defined nowhere, and I don't use any library for linking. With such an interface class, I thought I would have to defined a subclass of IPanelCCallback and define the ConvertStringToProperty method.

View 6 Replies View Related

Visual C++ :: Polymorphic Methods In Abstract Class

Oct 2, 2013

Imagine if there is an abstract class with a method (say output or print) which would be inherited by a few other classes. Later objects are created using the inherited classes, and the user wishes to call the above method twice, for eg (i) output/print to screen and (ii) output/print to a file. What is the best way to achieve that.

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved