|
googling s_isdir windows gives this hit: Porting To Win32!!!!. Seems like what you want. If not, maybe one of the other 27,000 results might help?
|
|
|
|
|
|
Hi.
I send a "TEXT" from Form1 to Form2.
Sometimes it's good, sometimes it's not good.
When you send "TEXT" from Form1 to Form2, TEXT disappears from Form2.show.
---------------------------------------------
Hide Expand Copy Code
Form1.h
private Burron1()
{
Form2::Form fm;
fm.viewText();
}
Form2.h
namespace Form {
public class Form
{
Form2()
{
void viewText();
}
}
}
void viewText()
{
textBox1->Text="TEXT";
}
-------------------------------------------------------------
Only when Text's Form, no problem. I cann't see other , only did mySql. This disappeared the "TEXT". textBox->Text is a Empty. I sent "TEXT" can't look for any.
I want to know how to make the appearing thing.
Say me , please.
Thank you.
|
|
|
|
|
private Burron1()
{
Form2::Form fm;
fm.viewText();
}
You create a local instance of Form2 in the above method, and then call viewText . But as soon as you return from that method, the variable fm goes out of scope and the form is destroyed. You need to create the form outside this method so it remains active until you decide to destroy it.
|
|
|
|
|
Is it a native or managed c++ code? 
|
|
|
|
|
I am a newbie to C++ programming and currently working on a program using Abstract Factory design pattern and linked list to store the objects and display them.
The user is expected to select whether the entry is for a management staff or Junior staff then save the parameters in the linked list and display them too.
I have created the abstract factories and the linked list but I am stuck on how to save the objects and display them with the linked list.
I need help with how to pass the staff object to the linked list and display them.
The AddNode and PrintList functions of the Linked list aren't working. (StaffMain.cpp).
Thank you.
I have five files - Staff.h, Staff.cpp, StaffList.h, StaffList.cpp and StaffMain.cpp
The codes are below
Staff.h
<pre>#pragma once
#include<string>
class Staff
{
private:
std::string Name;
std::string Address;
int age;
public:
Staff() {
Name = "";
Address = "";
age = 0;
}
Staff(std::string zName, std::string zAddress, int zage)
{
Name = zName;
Address = zAddress;
age = zage;
}
virtual void display() = 0;
virtual void input() = 0;
};
class JuniorStaff : public Staff {
private:
std::string Name;
std::string Address;
int age;
std::string staffLevel;
public:
JuniorStaff() {
Name = "";
Address = "";
age = 0;
staffLevel = "";
}
void input();
void display();
};
class MgtStaff : public Staff { private:
std::string Name;
std::string Address;
int age;
std::string mgrLevel;
public:
MgtStaff() {
Name = "";
Address = "";
age = 0;
mgrLevel = "";
}
void input();
void display();
};
class StaffFactory
{
public:
virtual Staff* staffDetails() = 0;
};
class JuniorStaffFactory :public StaffFactory
{
public:
Staff* staffDetails()
{
return new JuniorStaff();
}
};
class MgtStaffFactory :public StaffFactory
{
public:
Staff* staffDetails()
{
return new MgtStaff();
}
};
Staff.cpp
#include<iostream>
#include<string>
#include"Staff.h"
using namespace std;
void Staff::input()
{
}
void Staff::display()
{
cout << "The staff name is " << Name << endl;
cout << "The address of staff is " << Address << endl;
cout << "The staff age is " << age << "years" << endl;
}
void JuniorStaff::input()
{
cout << "Enter staff name: " << endl;
cin.ignore();
getline(cin, Name);
cout << "Enter address of staff: " << endl;
cin.ignore();
getline(cin, Address);
cout << "Enter staff age: " << endl;
cin.ignore();
cin >> age;
cout << "Enter staff level: " << endl;
cin.ignore();
getline(cin, staffLevel);
}
void JuniorStaff::display()
{
cout << "The staff name is " << Name << endl;
cout << "The address of staff is " << Address << endl;
cout << "The staff age is " << age << "years" << endl;
cout << "The staff level is " << staffLevel << endl;
}
void MgtStaff::input()
{
cout << "Enter staff name: " << endl;
cin.ignore();
getline(cin, Name);
cout << "Enter address of staff: " << endl;
cin.ignore();
getline(cin, Address);
cout << "Enter staff age: " << endl;
cin.ignore();
cin >> age;
cout << "Enter Management level: " << endl;
cin.ignore();
getline(cin, mgrLevel);
mgrLevel = mgrLevel;
}
void MgtStaff::display()
{
cout << "The staff name is " << Name << endl;
cout << "The address of staff is " << Address << endl;
cout << "The staff age is " << age << "years" << endl;
cout << "The Manager level is " << mgrLevel << endl;
}
StaffList.h
#pragma once
#include"Staff.h"
class List {
private:
class Node {
friend class List;
StaffFactory* newstaff;
Node* next;
public:
Node()
{
this->newstaff = NULL;
this->next = NULL;
};
Node(StaffFactory* c, Node* n)
{
this->newstaff = c;
this->next = n;
}
};
List::Node* head;
List::Node* curr;
public:
List();
void AddNode(StaffFactory* c);
void PrintList();
};
StaffList.cpp
#include<iostream>
#include<string>
#include"StaffList.h"
#include"Staff.h"
using namespace std;
List::List() {
head = NULL;
curr = NULL;
}
void List::AddNode(StaffFactory* c) {
List::Node* n = new List::Node;
n->next = NULL;
n->newstaff = c;
if (head == NULL) {
head = n;
}
else
{
curr = head; while (curr->next != NULL)
{
curr = curr->next;
}
curr->next = n;
}
}
void List::PrintList() {
curr = head;
while (curr != NULL) {
curr->newstaff->staffDetails();
curr = curr->next;
}
}
StaffMain.cpp
#include <iostream>
#include<string>
#include"Staff.h"
#include"StaffList.h"
using namespace std;
int main()
{
List stafflist;
int choice;
cout << "Select type of staff: " << endl;
cout << "1: Junior Staff" << endl;
cout << "2: Management Staff" << endl;
cout << "Selection: ";
cin >> choice;
cout << endl;
StaffFactory* newStaff;
switch (choice)
{
case 1:
newStaff = new JuniorStaffFactory;
break;
case 2:
newStaff = new MgtStaffFactory;
break;
default:
cout << "Invalid selection!!!" << endl;
newStaff = NULL;
break;
}
if (newStaff != NULL)
{
Staff* c = newStaff->staffDetails();
c->input();
c->display();
stafflist.AddNode(newStaff);
Staff* d = newStaff->staffDetails();
d->input();
stafflist.AddNode(newStaff);
stafflist.PrintList();
}
}
|
|
|
|
|
EjireK wrote: The AddNode and PrintList functions of the Linked list aren't working. You will need to be much more specific than that. Exactly what does "not working" mean, and where in the code do the failures occur.
As a quick exercise you could write a simple linked list that holds basic types (integers for example) and work on that until you can see exactly how to make it work correctly. You can then adapt that skeleton to handle any object type. Next step is to create the basic staff type and process objects of that type into the list. Finally you can expand it to add the other child types. Taking things a step at a time is much better, and easier, than trying to create a full system in one go.
|
|
|
|
|
For clarity, my challenge is with passing the abstract factory class object to the Linked list to create the node and to display it. The program does not generate any error currently as it successfully prompts the user to select which type of staff to create then prompts the user to specify the parameters.The linked list works with creation of staff object without the abstract factory but the exercise specifies states that I should use abstract factory with linked list to save the staff objects and display it. I’ve been unable to use the linked list with the abstract factory class object. I think my problem is in the StaffMain.cpp where I’m to specify the factory object to pass to the linked list but can’t seem to get that working. Thank you.
|
|
|
|
|
I am afraid that I do not have the time to analyse all that code. As I mentioned above, get a working linked list first that you know can handle simple objects. Once you have that logic working, then adapting it to handle any other object type is fairly trivial.
|
|
|
|
|
Thank you for your reply.
As advised, I have worked on a simple linked list storing integer values.
My simple linked list program has add node and display functions. The add node is working fine when the parameters are passed in the main program but the display function only displays the last item added. the other integers added previously are not showing.
E.g for the program below, it only outputs 10 and the other integers are not displayed.
int List::add(int c)
{
cout << "Adding " << c << endl;
Link* temp;
temp = new Link(c);
if (temp == 0)
{
cout << "Memory allocation failed" << endl; }
head = temp;
return c;
}
void List::display()
{
Link* temp = head;
cout << "Displaying list:" << endl;
while (temp !=NULL)
{
cout << "Value of object is " << temp->i <<endl;
temp = temp->Next;
}
}
int main()
{
List list;
list.add(6);
list.add(8);
list.add(10);
cout << endl;
list.display();
cout << endl;
}
|
|
|
|
|
Why would you expect it to do anything else at no point do you chain the entries you just throw earlier entries away
I suggest you look at what List::add does because all you are doing is overwriting "head"
Contrast it to what List::AddNode does in the code above which does actually create a chain
In vino veritas
|
|
|
|
|
In addition to Leon's comments above ... think about the logic. A linked list must have a constant pointer to the start of the list, the 'head'. Each item in the list should contain one or more data items, and a pointer to the next item. The head pointer should only be allocated once, when the list is first created. Each subsequent item should be chained to the node at the end of the chain. You can keep a pointer to the last item, or let the add method iterate through the list to find it.
|
|
|
|
|
Quote: The AddNode and PrintList functions of the Linked list aren't working. (StaffMain.cpp).
I don't know about AddNode(), but your PrintList() function doesn't print anything: it calls the function staffDetails(), and maybe you intended that function to print out some information, but what it does instead is create a new object, which by the way creates a memory leak because you're not using the return value.
I think your problem is that your list stores factories, not staff, and that some(?) of the functions don't do what their name implies.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
I am a beginner in programming and I am trying to solve this problem using queues. I can't seem to come with an idea to solve it.
Can you help please, it is a problem just to learn about how to approach queue problems.
This is the problem:
Tasks - Google Docs[^]
|
|
|
|
|
As with any problem, the approach is to examine the question carefully. Try to break it down into small parts and figure out how each part can be solved in order to feed into the next part. Draw diagrams on paper and do manual calculations to see what timings result.
I am not sure what is meant by " the quantity of rows and columns of the glade."
|
|
|
|
|
The solution is called a scheduler ... google "tutorial task scheduler in c"
In vino veritas
|
|
|
|
|
Hello
How do I check if XXX USB filter driver be installed by MFC?
Thanks
Vincent
|
|
|
|
|
|
I am trying to solve this problem through dynamic programming:
You are given a matrix of n rows and m columns. There’s an integer number on each cell of the board and the rabbit staying at the upper-left corner.
Collect the greatest sum possible, such that the rabbit can move in only two directions:
2 cells to the right and 1 cell down (x+2, y+1); 2 cells down and 1 cell to the right (x+1, y+2);
Input:
The first line contains two naturals n and m (1 ≤ n, m ≤ 10^3) – the quantity of rows and columns of the matrix.
The next n lines contain m numbers – the values of the matrix elements.
The upper-left corner’s coordinates are (1, 1), the lower-right corner’s – (n, m).
Output:
The greatest sum possibly collected. If the r rabbit can’t reach the lower-right corner, output «-».
Input1:
3 3
5 0 0
0 1 2
1 0 1
Output1:
-
Input2:
4 4
5 2 1 0
1 0 0 0
2 1 3 0
0 0 1 7
Output2:
13
This the code I tried to develop:
#include <iostream>
#include <algorithm>
using namespace std;
void findMaxSum(int *a[], int r, int c)
{
int **res = new int*[r];
for (int i = 0; i < r; i++) {
res[i] = new int[c];
for (int j = 0; j < c; j++)
res[i][j] = -1;
}
for (int i = 0; i < r-1; i++) {
for (int j = i; j < c-1; j++) {
res[i + 1][j + 2] = max(a[i][j] + a[i + 1][j + 2], res[i + 1][j + 2]);
res[i + 2][j + 1] = max(a[i][j] + a[i + 2][j + 1], res[i + 2][j + 1]);
}
}
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++)
cout << res[i][j] << " ";
cout << endl;
}
delete[] res;
}
int main() {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int r, c;
cin >> r >> c;
int **a = new int*[r];
for (int i = 0; i < r; i++) {
a[i] = new int[c];
}
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++)
cin >> a[i][j];
}
findMaxSum(a, r, c);
delete[] a;
return 0;
}
Could you help which right for or while loop to use to calculate such sum?
|
|
|
|
|
|
The Inseertobject does its job inserting a red bullet bitmap however it shifts over all the text by one byte as it puts a leading X'3F' I tried using ReplaceSel
shifting the text back one byte but upon display that line got duplicated
Thanks
|
|
|
|
|
You need to show the code and explain in more detail what you mean by "upon display that line got duplicated".
|
|
|
|
|
first off I am trying to write a front end to debugger sort of like visual studio I have a red bullet and the insert object works it places it in the first position of the buffer but the result is it shifts over the text in the rich buffer. The X'3F' seems to represent the red bullet bmp so I wrote code to shift everything over to the left 1 byte however seems like the lines get duplicated meaning
this is what in the rich edit before " STM R14,R12,12(R13) "
After the insertobject " LR R3,R15 "
" STM R14,R12,12(R13) "
" LR R3,R15
I cant cut and paste the rich edit display correctly but the insert object puts the bullet bmp where I want it, it just pushes the text to the right one byte thought if I wrote code to sh*t it over that would straighten it out but all did was display the STM line twice
This my code
myoleptr->InsertObject(&reobject);
int i;
RichListing->GetLine(RichListing->LineFromChar(-1), (LPTSTR)&buffer, 132);
for (i = 1; i < 132; i++)
buffer[i] = buffer[i + 1];
buffer before
0x00000004BEF4C2C0 3f 20 20 20 5f 20 20 20 20 20 20 20 32 33 20 20 20 20 20 20 20 20 30 30 30 30 30 30 20 20 20 20 ? _ 23 000000
0x00000004BEF4C2E0 20 20 20 20 20 20 20 20 20 53 54 4d 20 20 20 52 31 34 2c 52 31 32 2c 31 32 28 52 31 33 29 20 20 STM R14,R12,12(R13)
0x00000004BEF4C300 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0x00000004BEF4C320 20 20 20 20 20 20 20 20 30 30 30 32 31 30 35 31 0d 00 cc cc cc cc cc cc cc cc cc cc cc cc cc cc 00021051..ÌÌÌÌÌÌÌÌÌÌÌÌÌÌ
0x00000004BEF4C340 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ
0x00000004BEF4C360 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ
0x00000004BEF4C380 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ
0x00000004BEF4C3A0 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ
buffer after
0x00000004BEF4C2C0 3f 20 20 5f 20 20 20 20 20 20 20 32 33 20 20 20 20 20 20 20 20 30 30 30 30 30 30 20 20 20 20 20 ? _ 23 000000
0x00000004BEF4C2E0 20 20 20 20 20 20 20 20 53 54 4d 20 20 20 52 31 34 2c 52 31 32 2c 31 32 28 52 31 33 29 20 20 20 STM R14,R12,12(R13)
0x00000004BEF4C300 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0x00000004BEF4C320 20 20 20 20 20 20 20 30 30 30 32 31 30 35 31 0d 00 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc 00021051..ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ
0x00000004BEF4C340 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ
0x00000004BEF4C360 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ
|
|
|
|
|
I am not sure that I can see what is wrong with that. Anything inserted into the control will take space and thus move everything else along.
|
|
|
|
|
Richard
I think the selection range has to be in line with the number of characters that are in
LPCTSTR lpszNewText,
of the null terminated string parameter of ReplaceSel
When you InsertObject a bitmap that bitmap depending on its size takes up a certain amount of characters depending among other things the size of font of the
current selection and the size of the bitmap. I am not sure if there is a some way to calculate this i.e. if you have a string and you want to know how many pixels it takes you do GetTextExtent. the REOBJECT structure doesn't seem to have parameters for the size of the bitmap like BITBLT I just played around with the string and the selection size and got it to align
|
|
|
|