Questions tagged [c++]

860067 questions
1

votes
2

answer
1.3k

Views

Deserializing just a single node of a JSON response

I have a json response like { "appStatus":{ "status":true }, "lastSyncDate":"06-07-2013 13.54.27", "configResponse":{ "status":{ "status":true }, "configs":{ "APPLOGENABLED":{ "configCode":"APPLOGENABLED", "configDesc":"enable or disable logging from front end", "configType":"TAB", "configValue":"Y...
Shafqat Masood
1

votes
4

answer
8.7k

Views

C++ can you please help me with Composition example app?

Can you please help me with writing composition example app in C++ ? I need such hierarchy : Class AppleCake inherits from base class Cake, and there is class CakePacket, which has 4 Cakes. I write some part of code, but the problem is I don't know how to add 4 Cake objects to CakePacket. I'm a beg...
user2550609
1

votes
2

answer
3.2k

Views

Invoking Overloaded Function on Google Mock

I'm attempting to test an abstract class using Google Mock. Following the forDummies guide, I've constructed a mock of my class: AbstractFoo.h class AbstractFoo { public: virtual void setSize(int w, int h) = 0; void setSize(const QSize& s); // implemented as calling above function } MockFoo.h #inclu...
bdares
1

votes
1

answer
1.4k

Views

clear error provider message when user input change to valid

Inside form I have txtbox with following event code private void txtCode_KeyPress(object sender, KeyPressEventArgs e) { char ch = e.KeyChar; if (!Char.IsDigit(ch) && ch != 8) { e.Handled = true; errorProvider1.SetError(txtCode, "numbers only"); } } Error icon is shown right to the txtbox with error...
panjo
0

votes
2

answer
35

Views

how to convert an array of integers (1s and 0s) to their ascii equivalents in c#

I have an array of integer 1s and 0s (possibly need to get converted to byte type?). I have used an online ASCII to binary generator to get the equivalent binary of this 6 digit letter sequence: abcdef should equal 011000010110001001100011011001000110010101100110 in binary. So in c#, my array is [0,...
mheavers
0

votes
1

answer
17

Views

Getting 'Segmentation fault' error when trying to load text file into a dynamically allocated 2d array

I'm not sure exactly is causing this error, as the code was working for a little while, but I must've changed something that messed it up and I've never been able to get it working again. This is the data in the text file being loaded into the 2d array: 10 8 0 255 255 255 0 0 255 255 255 0 255...
Spago
0

votes
0

answer
32

Views

Sorting a select list item with number in string

I have an List of strings that I will pull from an enum and I need to sort in alphabetical order then by number and some strings won't have numbers, those strings should be at the end of the list. List = "Incl 11 Incl 12 Excl 4 Incl 3 Other Incl 4 Incl 10 Incl 11 Excl 10 Incl 1 Incl 2 Withdrew...
AxV
2

votes
3

answer
40

Views

How to demonstrate the unpredictable order of fork() in C?

I'm really stuck on this assignment. It is a pretty simple program I have to write in C. The idea is to demonstrate the use of fork() and wait(). The instructions say to "Perform exactly 15 iterations before terminating. In each iteration, the program will create 10 child processes (p0 to p9). Each...
John Smith
32

votes
5

answer
1.7k

Views

How do I write a maintainable, fast, compile-time bit-mask in C++?

I have some code that is morally like this: #include enum Flags { A = 1, B = 2, C = 3, D = 5, E = 8, F = 13, G = 21, H, I, J, K, L, M, N, O }; void apply_known_mask(std::bitset &bits) { const Flags important_bits[] = { B, D, E, H, K, M, L, O }; std::remove_reference::type mask{}; for (const auto& b...
Alex Reinking
-1

votes
1

answer
20

Views

Parse options with binary masks

and good evening! I am currently creating an executable for linux. However, when parsing the options of my executable, I encounter errors. I do not understand why the "-p" option passes the verification conditions.. The header file my project: # define O_LONG 0x6c // -l # define O_RECUR...
7hsk
-1

votes
0

answer
25

Views

Models Join - Asp.NET MVC [on hold]

I'm trying to show on my view the BrandName of each ModelName... What am I doing wrong? I know that my Brands is null like the image below and when I put the prop BrandName inside clsModel I get what I want, but I need to do this with Foreign Key Annotation public class clsBrand { [Key] public int B...
LeoHenrique
-2

votes
1

answer
25

Views

Find hours between two dates [duplicate]

This question already has an answer here: Difference between 2 DateTimes in Hours? [duplicate] 5 answers Suppose I have two dates: for example: DateTime date1 = new DateTime(2019, 2, 20, 16, 0, 0); DateTime date2 = new DateTime(2019, 2, 20, 23, 0, 0); How can I find how many hours between the two d...
Ivan Aramazov
1

votes
1

answer
20

Views

error: lvalue required as left operand of assignment (swrots) [duplicate]

This question already has an answer here: how do i debug error: lvalue required as left operand of assignment? 4 answers As I was trying to restore an old Star Wars mud I ran into this bug and unfortunately I am stuck. This is the error I recieve when I try to compile "act_move.c" act_move.c:591:...
Code Lyfe
0

votes
2

answer
21

Views

Linq Collection Sorting

I need to sort countries in this collection using LINQ: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp5 { class Program { class Country { public string Name { get; set; } public int Population { get; set; } pub...
Aca Licic
0

votes
2

answer
21

Views

reopen a file using openat

As it seems, it is possible to use openat() to reopen an already opened file. For instance on my Linux system I can do the following: #define _GNU_SOURCE #include #include #include int main(void) { int fd1 = open(".", O_PATH); if (fd1 == -1) { perror("open"); return 1; } int fd2 = openat(fd1, "."...
peeed
0

votes
1

answer
19

Views

How do I remove the password from a private key in C# using Bouncy Castle?

I want to remove a password from a private key, so I can use the key without a password(finder). This is the code: StringReader privateKeyPemStringReader = new StringReader(privateKeyPem); PemReader privateKeyPemReader = new PemReader(privateKeyPemStringReader, new StringPasswordFinder("secret")); A...
frankhommers
5

votes
2

answer
154

Views

How to leverage generics to populate derive class models to avoid code duplication?

I am having 2 types like and each type have different processing logic. Based on that processing I am preparing a result and returning it to the consumer (mvc application,console app etc..) Type 1 Type 2 Now the problem is some code is common across both the types. The only part that differs is the...
ILoveStackoverflow
0

votes
0

answer
3

Views

How to use Microsoft.Office.Interop.Outlook.CalendarView and Microsoft.Office.Interop.Outlook.CalendarViewClass

I'm using Interop for sending meeting via Outlook, but I am not able to get the meeting list items for that particular user. I want to get the details of the to specify meetings from the lost of meetings items that are available in the calendarview. However, I cannot find a property Outlook.Calendar...
Kalpana Ramanan
-2

votes
0

answer
16

Views

access input values in a different scope c++

so i have this code , i am currently a beginner and i am practicing inheritance. my question is can take the following code, int a; int b; std::cout a; std::cout b; and place it in a function/class and still be able to pass variables a and b into setbirdlength function. as of now the two variable...
learner C
1

votes
0

answer
13

Views

Mapping with generic destination doesn't work?

I'm trying to build out a hierarchy of mapping profiles to simplify creating mappings for new objects that fit in this hierarchy. But I'm having trouble getting some mappings to work. A mapping I added using a generic type parameter doesn't seem to work when it's the destination type, however it wo...
Jeff Mercado
1

votes
1

answer
3.2k

Views

How can I draw a circle with antialiasing and gaussian line intensity using EmguCV (OpenCV)?

I need to draw the most perfect circle possible. EmguCV seems to lack an anti-aliasing option. I'm trying to use SmoothGaussian, but the circle still does not look good/smooth enough. Also, the circle line intensity should have Gaussian shape (i.e.: brighter in the center). How can I achieve that? H...
Pedro77
1

votes
3

answer
825

Views

Listing drivers in ring0/kernel?

Just a question, I'm wondering if it's possible to hook in to Ring0/Kernel to display the list of loaded drivers running within the kernel? Would I need to write a driver to do so? Similar to how you can list all the running processes quite easily. Oh and this is in C++ / Windows.
1

votes
2

answer
2k

Views

Add character in middle of string

Been stuck on this for bloody ages. Seems like no easy way to do it! Would appricate some help, thanks! #include #include #include char (char *s, const int len) { { static const char alphanum[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "123456789"; for (int i = 0; i < len; ++i) { s[i] = alphanum[(sizeof(alp...
raging fire
1

votes
1

answer
96

Views

Extracting an array of a member variable from a vector

Let's say I have a struct: struct Foo { float A; float B; float C; }; And I have a vector of the struct: std::vector vFoo; And a function that takes arrays of floats (or whatever the same type as Foo members): float foo_floats(const float a[], const float b[], const float c[]); My question is, is th...
Ernest Sato
1

votes
4

answer
3.8k

Views

C# create custom dialog result form

I have a two forms in C#, one I intend to use as a dialog result and the other is the "main" form. how do I set up the other form so that the code in form1 waits until the second form is dismissed before resuming executing the next line of code?
fifamaniac04
1

votes
1

answer
6.6k

Views

Using an embedded .dll in an executable

Okay. So I know there's lots of questions about how to embed dlls inside exes, but my problem is rather different. (Specifically, I'm using the fmod library to play sounds in my program, and I'm embedding the fmod.dll, but that's beside the point.) I am using Visual C++ 2010 Ultimate. I have succes...
Pojo
1

votes
1

answer
90

Views

boost foreach with protected inheritance of container

I'm getting a compile time error with the following code. The error pops up on the use of BOOST_FOREACH on line 23: 17 class MyVec: protected std::vector 18 { 19 public: 20 void add(int i) { this->push_back(i); } 21 void print() 22 { 23 BOOST_FOREACH(int i,...
user2604093
1

votes
1

answer
248

Views

Why does GTK+ define TRUE and FALSE?

Why do GTK+ and several other frameworks provide TRUE and FALSE macros? Is there any advantage to using TRUE and FALSE instead of the built-in C values true and false? You can see their implementation here: http://www.gtk.org/api/2.6/glib/glib-Standard-Macros.html#TRUE:CAPS
Will Kunkel
1

votes
3

answer
2.7k

Views

Difference between multi dimensional arrays and array of pointers

I always believed that in C : int a[5][3]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; refers to an array of arrays and in memory fifteen contiguous blocks are stored but a[0] is the pointer to a[0][0] and a[1] is the pointer to a[1][0] and so on. So I thought it to be similar to be an array of pointers....
user1369975
1

votes
3

answer
5.6k

Views

C# not reading excel date from spreadsheet

I uploaded an excel spreadsheet using Microsoft.Office.Interop.Excel. When I try to read cells with a date value in order to insert it into my data set, its not being recognized as a date and it comes up as a random number? this is the way that I refer to the cell: Excel.Range startDate = objsheet.g...
user2140832
1

votes
2

answer
72

Views

C++ template method and obtaining result - design

I've such an interface class: class MyInterface { public: virtual void DoStuff() = 0; virtual Result GetResult() = 0; }; and simple abstract method, which realizes template pattern: class Abstract: public MyInterface { public: void DoStuff() { DoAFoo(); BakeAPie(); PrepareResult(); } virtual DoAFo...
Dejwi
1

votes
1

answer
698

Views

Can I have a FileUpload control inside the Complete step of a Wizard that is surrounded by an UpdatePanel?

I have a Wizard control surrounded with an UpdatePanel and I want a FileUpload control within the complete step. I am aware that a FileUpload control will only work inside an UpdatePanel if a trigger is added to the UpdatePanel, but, my UpdatePanel cannot find the Button1 control in the example bel...
sourkrause
1

votes
2

answer
64

Views

Printing to an element of MainWindow from an outside class

I have created a set of watcher/helper classes that monitor an outside application, and I would like these to print to a log window inside my MainWindow's ui when changes are made. My idea was to create this watcher inside a thread in main, but I am not sure the best way to link it to my MainWindow....
c0nn
1

votes
1

answer
311

Views

GNU version issue with gnu++0x standard

I need to compile code with two compiler versions: g++ (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3 g++ (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 I have a piece of code in a header file like this: template class Constant { ... /*constexpr*/ static const RealType Pi = 3.141592653589793238462643383279502884197169...
Michael
1

votes
5

answer
3.8k

Views

Kendo MVC fire Create method on Update call

I am using Kendo UI Grid with MVC 4 and it works great with only one exception. If I add a row in the grid, and after that update a row, It end up adding a row rather than updating it. What I can tell is that if I press add, the program enters the Create method in my MVC Controller, if I press Updat...
user1106784
1

votes
3

answer
9.1k

Views

Node and Binary Tree Constructor and Destructor Segfaulting

I've seen this question asked before here, specifically Generic binary tree node destructor issue and Binary Search Tree Destructor among other things but so far the answers I got was to set the Node pointers to NULL in the constructor. Here is the code of my constructors and destructors for the Nod...
1

votes
1

answer
672

Views

Libclang API to get function definitions defined in a different file

Suppose I have two files main.c and func.c func.c is called from main.c's main function. Normally, I would generate main.o and func.o and linker would find definition of func and tie it up to it's call in main .c Now, I want to do same thing through libclang APIs. This is for a Doxygen type code bro...
user763410
1

votes
1

answer
837

Views

Clean up img tags in a full html string

I have a full HTML string. It looks like this: This is a test What I would like to do is clean up the source. I want to remove all widths and heights in the img tags only. I want to preserve the ID and SRC attributes.
Bill Daugherty
1

votes
1

answer
1.6k

Views

Using a validation summary to display label text

I have taken over maintenance of a site that makes calls through a WCF service. There is a validation summary that displays in a message box for some validators on the client-side. I also have a label that fires if any exceptions arise from my web service calls. After tweaking the layout, the label...
Rex_C
1

votes
3

answer
1.5k

Views

Need to enable UITextField in row of UITableView when cell is selected in iOS

I have created a custom cell that places a UITextField in each row of a UITableView. What I would like to do is enable the UITextField for a particular row (i.e. activate the cursor in that textfield), when the user presses on anywhere inside the cell. I have the following method where I try to do...
syedfa

View additional questions