C/C++ :: How To Declare A Bit String
Sep 29, 2013How i can declare a bit string in C++ .....
View 9 RepliesHow i can declare a bit string in C++ .....
View 9 RepliesHow to declare functions in C++
View 1 Replies View RelatedI remember that the syntax exists I just don't remember what it is.I want to write a conditional function () prior to main (). in that function I'm using a variable that isn't introduced until main (). How do I let C know that I will be int'ng this function prior to the point where it is going to be accessed so that it doesn't freak out? alternatively is it possible to int the variable in both main() and my conditional function so that it exists? I imagine this would cause an issue because I would essentially be int'ng it twice.
I've done the cursory google searches however I don't think I'm using the correct keywords to get the results I'm looking for. If necessary I would be more than happy to post the code it's just a simple 40 line homework assignment.
I have this class with template:
template<template<class, class> class ContainerType>
class Movie {
public:
typedef ContainerType<Actor*, std::allocator<Actor*> > Container;
and i have a member func to find actor in movie according to actor id:
const Actor* findActor(int id) const {
typename Container::iterator it;
Actor* p(NULL);
it=actors.begin();
std::for_each(it,actors.end(),(*it)->getId()==id?p=*it:0);
if (p==*actors.end()) return NULL;
return p;
}
I receive error that no match for operator= in it.
How to declare correct iterator ?the type of actors is Container..
Can you declare a stack globally?
Code:
stack< int > stk;
It has been a few years since I have had to do this, but I need to declare a method in my base class, but produce no code for it. Then when this library is used by my second project I will derive a class from this base class and put the code into it there. How is this possible? I used to know how but do not remember how now.
The library is a static library designed for linking with both 32bit and 64bit Windows applications to handle a lot of the tedious stuff with Windows programming. The method in question handles specific command inputs. However, since each program that uses this library will have different uses for these commands, I want to leave it up to the user to code their own handling, but require it to be coded in the derived class.
is it possible to don't declare an object for a class and use the function of this class ? i saw a code use this but i cannot find it again .
View 7 Replies View Relateddecalration won't allocate storage, while definition will. This is a test program:
#include <iostream>
using namespace std;
extern int ei;
int i;
[Code].....
Others are all fine in this program except ei.
compiler error: undefined reference to ei.
I understand ei is only declared so there is no memory address, but when I do ei=1, then ei completed it's definition, why still cannot use pei to get it's address?
How to declare variable for all void() as I have another void s in my C++ program. I want to have a variable that can use for all the void and not only in a simple void.Is it possible?
View 17 Replies View RelatedI write these code in 2 different ways and I get the same result. I just want to make sure that they both are for declare a pointer using "auto"
The first one:
int varName = 10;
auto var1 = &varName;
cout << var1 << endl; //prints, varName address
cout << *var1 << endl; //prints, varName value
The second one:
int varName = 10;
auto *var2 = &varName;
cout << var2 << endl; //prints, varName address
cout << *var2 << endl; //prints, varName value
It doesn't matter if I put dereference operator or not, I still get the same result. I just want to make sure that var1 and var2 are both a pointer.
How can I forward declare an inner class?
I currently have this:
Code:
class Enigma
{
public:
Enigma()=delete;
Enigma(char r1,char r2,char r3,char r4, char r5, char r6, char r7, char r8, char r9, char r10);
~Enigma(){delete[] R;}
Enigma(const Enigma& rhs)=delete;
Enigma& operator=(const Enigma& rhs)=delete;
[Code]...
I'd like to be able to define Rotor outside of Enigma, but the compiler complains about incomplete types.
What is the purpose to declare constructor as protected?
View 13 Replies View RelatedI suspect that C++11 would make it possible to declare high rank vectors such as Code: int N = 15; // chosen arbitrary rank vector<vector<vector<...<vector<double>>>>..> vec; // N layers of nested vectors Is there a way to declare such a vector of rank N (given a fixed integer rank N)?
Heuristically I would like to write the declaration like this: Code:
vector<double> A;
vector<A> vec[0];
for(int i=1; i<N; i++)
{
vector<vec[i-1]> vec[i];
} Is there a way to use the new variadic templates to make this work?
I'm building a box to take in several arrays of different lengths. one group happens every 10 seconds. one of them happens every 5 seconds. this is from a weather station.
10 sec
subgroupA[14]
subgroupB[24]
subgroupC[17]
subgroupD[12]
subgroupE[34]
5 sec
subgroupC[17]
I plan to retransmit them, substantially unchanged at a lesser rate to save radio power over a serial data link. buried in groupD, I want to change a few chars before retransmit.
I don't want to go to the trouble of doing a structure for each of them since most will be resent unchanged. some entries are chars, some are decimal, some are a mix. I guess it might be convenient to further define groupD, maybe not.
what is the best way to declare the group? I want them to be contiguous since that's how they will end up in the tx buffer. Each subgroup has its own checksum, so I planned it this way to make checksum more convenient.
I want to declare a global array and then use it in a few functions. When I want to assign any number to that array I face with this error:
Code:
a.c:11:6: error: expected expression before ']' token
n[]={1,2,3,4,5};
^
The code is:
#include <stdio.h>
int n[5]; // I need to define the array here to be global
int main () {
n[]={1,2,3,4,5};
[Code] .....
I am trying to learn how to declare a pointer to an array of characters. And here is the code i have written. But iam getting a warning saying assignment from incompatible pointer type p = s.
Code:
#include <stdio.h>
int main(int argc, char *argv[]) {
char (*p)[10]; // pointer to an array of 10chars
char s[10] = "Hello"
p = s;
printf("%s",p);
return 0;
}
Theres a class named "A" which has got a static function named "sfA".Now I instance an object of class A and call a method from A called "fA".
The method fA calls sfA. And now the issue is: i need the value of a member from the object which called fA respectivly sfA, inside sfA.Is there a smarter way to get the value of the member as to declare an new parameter for the sfA? sfA has to be static.
Basically, I need to set a variable outside of the constructor and make it accessible to the entire class.
It would need to work something like this:
#include <iostream>
#include <string>
template <typename MT> class CallbackFunction
{
[Code].....
I need to declare the number of vectors according to an input parameter call NUM HOST.
For example, if NUMHOST=4, I need to declare 4 vectors and the name of the vectors seriam: vector1, vector2, vector3, in struct for would be vectori...
for (int i = 0; i <= NUMHOST; i++)
int vector????[3];
i am trying to describe the unusual situation where you declare a class member function with this format:
bool class::function_name(void) const
Specifically where the 'const' follows the parameter list. It is my understanding this is a very useful way of ensuring that whatever code you put in the function definition cannot change any data members of its class.
However I have recently read that this form of declaration should not be used as it leads to less optimized and slower code. Is this correct?
I know how to store numeric data using keywords int, long, float, and so on. I'm making my own program called "Who is your soul-mate".The only question I want to ask is what's the keyword for storing alphabet data? As you can see below on my source file. I want to replace "int" keyword with another keyword that can store alphabet data. It's all in standard C.
#include <stdio.h>
int soulm01, soulm02, soulm03;
int year_of_birth;
int main(void)
[Code].....
I am getting this error while trying to compile my program:
It says that my variables "nome, cognome, eta..etc" are being used for the first time in my "inserisci" function.
I tought that I could just declare them as global in my structure like I did in my code, but apparently this doesn't work.
Do I really need to declare them again outside of my structure? Isn't there another way?
Here is my code:
#include <stdio.h>
#include "readline.h"
void inserisci(void);
struct impiegato{
char nome[20];
char cognome[20];
int eta;
[code].....
#include <iostream>
#include <cmath>
using namespace std;
void summary();
const float below100 = 0.10;
const float after100 = 0.05;
[Code] .....
It cannot loop back to the top coding, cause what i want is the code can loop back to the 1st cout question, and it will asking over and over again, and how to declare a function for the summary report?
If we are making a library record for five book then we have to use for loop like title, author, subject, pages..etc
How will I call them in C#,
In c++ we st[5]; and we write st[i].title...etc
how we can make similar thing in c#
I need to make a program that will let the user input values and it will only stop accepting once the user has inputted a negative number then it will display its mode and frequency.
The problem is I can't find a way to let the user input values freely without asking first for the no. of values he will enter.
#include<stdio.h>
int main() {
int i,j,k=1,p,a[20],b[20],n,cnt=1,big;
clrscr();
printf("Enter the number of elements:
[Code] .....
i hit the point where i have two class templates that are dependent on each other (in detail, class a stores a pointer of class b), creating a cyclic include issue.
Usually i resolve this with a forward declaration, but i cant seem to figure out how to do it with a template class.In fact, ( i think) i got it to work for this :
Code:
template<typename T>
class a
{
public:
T x;
}
but not for this:
Code:
template<int b>
class b
{
public:
int getb(){return b;}
}
Where the template is not for a specific "type".